summaryrefslogtreecommitdiff
path: root/functable.c
diff options
context:
space:
mode:
authorMika Lindqvist <postmaster@raasu.org>2018-03-13 11:26:19 +0200
committerHans Kristian Rosbach <hk-git@circlestorm.org>2018-12-12 15:24:17 +0100
commitca28d020f11ecc22cb86accaee40996906280f7a (patch)
treef1ed5276a874d347e434f281d61a4c0bf5da8a3b /functable.c
parent59476a9cb490bb168fc9555c247739ded3fbcb01 (diff)
[ARM/AArch64] Add run-time detection of ACLE and NEON instructions under Linux.
* Use getauxval() to check support for ACLE CRC32 instructions * Allow disabling CRC32 instruction check
Diffstat (limited to 'functable.c')
-rw-r--r--functable.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/functable.c b/functable.c
index e0f0e40..93fbd23 100644
--- a/functable.c
+++ b/functable.c
@@ -12,6 +12,9 @@
#if defined(X86_CPUID)
# include "arch/x86/x86.h"
+#elif (defined(__arm__) || defined(__aarch64__) || defined(_M_ARM))
+extern int arm_has_crc32();
+extern int arm_has_neon();
#endif
@@ -65,7 +68,8 @@ ZLIB_INTERNAL Pos insert_string_stub(deflate_state *const s, const Pos str, unsi
#ifdef X86_SSE4_2_CRC_HASH
if (x86_cpu_has_sse42)
functable.insert_string=&insert_string_sse;
- #elif defined(ARM_ACLE_CRC_HASH)
+ #elif defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH)
+ if (arm_has_crc32())
functable.insert_string=&insert_string_acle;
#endif
@@ -93,6 +97,7 @@ ZLIB_INTERNAL uint32_t adler32_stub(uint32_t adler, const unsigned char *buf, si
functable.adler32=&adler32_c;
#if ((defined(__ARM_NEON__) || defined(__ARM_NEON)) && defined(ARM_NEON_ADLER32))
+ if (arm_has_neon())
functable.adler32=&adler32_neon;
#endif
@@ -113,10 +118,10 @@ ZLIB_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64
if (sizeof(void *) == sizeof(ptrdiff_t)) {
#if BYTE_ORDER == LITTLE_ENDIAN
-# if __ARM_FEATURE_CRC32
+ functable.crc32=crc32_little;
+# if __ARM_FEATURE_CRC32 && defined(ARM_ACLE_CRC_HASH)
+ if (arm_has_crc32())
functable.crc32=crc32_acle;
-# else
- functable.crc32=crc32_little;
# endif
#elif BYTE_ORDER == BIG_ENDIAN
functable.crc32=crc32_big;