Skip to content

Commit

Permalink
Unify detection of ARM getauxval code availability.
Browse files Browse the repository at this point in the history
We don't want to compile arch-specific code when WITH_OPTIM is not set,
and the current checks don't take that into account.
  • Loading branch information
Dead2 committed Sep 21, 2019
1 parent 9f16eae commit e0480bc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ endif()

if(WITH_OPTIM)
if(BASEARCH_ARM_FOUND)
add_definitions(-DARM_GETAUXVAL)
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/armfeature.c ${ARCHDIR}/fill_window_arm.c)
if(WITH_NEON)
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/adler32_neon.c)
Expand All @@ -541,7 +542,7 @@ if(WITH_OPTIM)
add_feature_info(ACLE_CRC 1 "Support CRC hash generation using the ACLE instruction set, using \"${ACLEFLAG}\"")
endif()
elseif(BASEARCH_X86_FOUND)
add_definitions("-DX86_CPUID")
add_definitions(-DX86_CPUID)
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/x86.c)
if(HAVE_SSE42CRC_INLINE_ASM OR HAVE_SSE42CRC_INTRIN)
add_definitions(-DX86_SSE42_CRC_HASH)
Expand Down
4 changes: 2 additions & 2 deletions deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ int ZEXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int level, int method,
int wrap = 1;
static const char my_version[] = PREFIX2(VERSION);

#ifdef X86_CPUID
#if defined(X86_CPUID)
x86_check_features();
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
#elif defined(ARM_GETAUXVAL)
arm_check_features();
#endif

Expand Down
8 changes: 4 additions & 4 deletions functable.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ extern Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned in
#endif

/* fill_window */
#ifdef X86_SSE2
#if defined(X86_SSE2)
extern void fill_window_sse(deflate_state *s);
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
#elif defined(ARM_GETAUXVAL)
extern void fill_window_arm(deflate_state *s);
#endif

Expand Down Expand Up @@ -90,12 +90,12 @@ ZLIB_INTERNAL void fill_window_stub(deflate_state *s) {
// Initialize default
functable.fill_window=&fill_window_c;

#ifdef X86_SSE2
#if defined(X86_SSE2)
# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2)
if (x86_cpu_has_sse2)
# endif
functable.fill_window=&fill_window_sse;
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
#elif defined(ARM_GETAUXVAL)
functable.fill_window=&fill_window_arm;
#endif

Expand Down
4 changes: 2 additions & 2 deletions inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ int ZEXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int windowBits, const c
int ret;
struct inflate_state *state;

#ifdef X86_CPUID
#if defined(X86_CPUID)
x86_check_features();
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
#elif defined(ARM_GETAUXVAL)
arm_check_features();
#endif

Expand Down
2 changes: 1 addition & 1 deletion zutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void ZLIB_INTERNAL zng_cfree(void *opaque, void *ptr);

#if defined(X86_CPUID)
# include "arch/x86/x86.h"
#elif defined(__aarch64__) || defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
#elif defined(ARM_GETAUXVAL)
# include "arch/arm/arm.h"
#endif

Expand Down

0 comments on commit e0480bc

Please sign in to comment.