--- /dev/null
+/* arm.h -- check for ARM features.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifndef ARM_H_
+#define ARM_H_
+
+extern int arm_cpu_has_neon;
+extern int arm_cpu_has_crc32;
+
+void ZLIB_INTERNAL arm_check_features(void);
+
+#endif /* ARM_H_ */
+#include "zutil.h"
+
#if defined(__linux__)
# include <sys/auxv.h>
# include <asm/hwcap.h>
#endif
-int arm_has_crc32() {
+static int arm_has_crc32() {
#if defined(__linux__) && defined(HWCAP_CRC32)
return (getauxval(AT_HWCAP) & HWCAP_CRC32) != 0 ? 1 : 0;
#elif defined(ARM_NOCHECK_ACLE)
#endif
}
-int arm_has_neon()
-{
- return 1; /* always available */
+ZLIB_INTERNAL int arm_cpu_has_neon;
+ZLIB_INTERNAL int arm_cpu_has_crc32;
+
+void ZLIB_INTERNAL arm_check_features(void) {
+ arm_cpu_has_neon = 1; /* always available */
+ arm_cpu_has_crc32 = arm_has_crc32();
}
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/armfeature.c
armfeature.lo: $(SRCDIR)/armfeature.c
- $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/armfeature.c
+ $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/armfeature.c
crc32_acle.o: $(SRCDIR)/crc32_acle.c
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c
--- /dev/null
+/* arm.h -- check for ARM features.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifndef ARM_H_
+#define ARM_H_
+
+extern int arm_cpu_has_neon;
+extern int arm_cpu_has_crc32;
+
+void ZLIB_INTERNAL arm_check_features(void);
+
+#endif /* ARM_H_ */
+#include "zutil.h"
+
#if defined(__linux__)
# include <sys/auxv.h>
# include <asm/hwcap.h>
# include <winapifamily.h>
#endif
-int arm_has_crc32() {
+static int arm_has_crc32() {
#if defined(__linux__) && defined(HWCAP2_CRC32)
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0 ? 1 : 0;
#elif defined(ARM_NOCHECK_ACLE)
#endif
}
-int arm_has_neon()
+static int arm_has_neon()
{
#if defined(__linux__) && defined(HWCAP_NEON)
return (getauxval(AT_HWCAP) & HWCAP_NEON) != 0 ? 1 : 0;
return 0;
#endif
}
+
+ZLIB_INTERNAL int arm_cpu_has_neon;
+ZLIB_INTERNAL int arm_cpu_has_crc32;
+
+void ZLIB_INTERNAL arm_check_features(void) {
+ arm_cpu_has_neon = arm_has_neon();
+ arm_cpu_has_crc32 = arm_has_crc32();
+}
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#include "x86.h"
+#include "zutil.h"
#ifdef _MSC_VER
#include <intrin.h>
#ifndef CPU_H_
#define CPU_H_
-#if defined(HAVE_INTERNAL)
-# define ZLIB_INTERNAL __attribute__((visibility ("internal")))
-#elif defined(HAVE_HIDDEN)
-# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
-#else
-# define ZLIB_INTERNAL
-#endif
-
extern int x86_cpu_has_sse2;
extern int x86_cpu_has_sse42;
extern int x86_cpu_has_pclmulqdq;
#ifdef X86_CPUID
x86_check_features();
+#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM)
+ arm_check_features();
#endif
if (version == NULL || version[0] != my_version[0] || stream_size != sizeof(PREFIX3(stream))) {
#ifndef DEFLATE_P_H
#define DEFLATE_P_H
-#if defined(X86_CPUID)
-# include "arch/x86/x86.h"
-#endif
-
/* Forward declare common non-inlined functions declared in deflate.c */
#ifdef ZLIB_DEBUG
#include "gzendian.h"
-#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
-
-
/* insert_string */
#ifdef X86_SSE4_2_CRC_HASH
extern Pos insert_string_sse(deflate_state *const s, const Pos str, unsigned int count);
if (x86_cpu_has_sse42)
functable.insert_string=&insert_string_sse;
#elif defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH)
- if (arm_has_crc32())
+ if (arm_cpu_has_crc32)
functable.insert_string=&insert_string_acle;
#endif
functable.adler32=&adler32_c;
#if ((defined(__ARM_NEON__) || defined(__ARM_NEON)) && defined(ARM_NEON_ADLER32))
- if (arm_has_neon())
+ if (arm_cpu_has_neon)
functable.adler32=&adler32_neon;
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
functable.crc32=crc32_little;
# if __ARM_FEATURE_CRC32 && defined(ARM_ACLE_CRC_HASH)
- if (arm_has_crc32())
+ if (arm_cpu_has_crc32)
functable.crc32=crc32_acle;
# endif
#elif BYTE_ORDER == BIG_ENDIAN
int ret;
struct inflate_state *state;
+#ifdef X86_CPUID
+ x86_check_features();
+#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM)
+ arm_check_features();
+#endif
+
if (version == NULL || version[0] != PREFIX2(VERSION)[0] || stream_size != (int)(sizeof(PREFIX3(stream))))
return Z_VERSION_ERROR;
if (strm == NULL)
/* provide prototypes for these when building zlib without LFS */
#if !defined(WIN32) && !defined(__MSYS__) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
+# include "zbuild.h" /* For PREFIX() */
ZEXTERN uint32_t ZEXPORT PREFIX(adler32_combine64)(uint32_t, uint32_t, z_off_t);
ZEXTERN uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t, uint32_t, z_off_t);
#endif
#define MEMSET memset
#endif
+#if defined(X86_CPUID)
+# include "arch/x86/x86.h"
+#elif defined(__aarch64__)
+# include "arch/aarch64/arm.h"
+#elif defined(__arm__) || defined(_M_ARM)
+# include "arch/arm/arm.h"
+#endif
+
#endif /* ZUTIL_H_ */