From b1241585b2baf2e62b75febdee2757fc2d3f6488 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sat, 30 Jan 2021 15:04:27 +0000 Subject: [PATCH] Mac M1 build support proposal (minus rocksdb option) (#1743) --- include/my_global.h | 2 +- mysys/crc32/crc32_arm64.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/my_global.h b/include/my_global.h index e8ed7e037f0a3..da0d9920e064b 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -152,7 +152,7 @@ # if defined(__i386__) || defined(__ppc__) # define SIZEOF_CHARP 4 # define SIZEOF_LONG 4 -# elif defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) +# elif defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) || defined(__arm64__) # define SIZEOF_CHARP 8 # define SIZEOF_LONG 8 # else diff --git a/mysys/crc32/crc32_arm64.c b/mysys/crc32/crc32_arm64.c index 02c43c350c8ff..62606c7ddea53 100644 --- a/mysys/crc32/crc32_arm64.c +++ b/mysys/crc32/crc32_arm64.c @@ -4,6 +4,29 @@ #if defined(HAVE_ARMV8_CRC) +#if defined(__APPLE__) +#include + +static int pmull_supported; + +int crc32_aarch64_available(void) +{ + int ret; + size_t len = sizeof(ret); + if (sysctlbyname("hw.optional.armv8_crc32", &ret, &len, NULL, 0) == -1) + return 0; + return ret; +} + +const char *crc32c_aarch64_available(void) +{ + if (crc32_aarch64_available() == 0) + return NULL; + pmull_supported = 1; + return "Using ARMv8 crc32 + pmull instructions"; +} + +#else #include #if defined(__FreeBSD__) static unsigned long getauxval(unsigned int key) @@ -50,6 +73,7 @@ const char *crc32c_aarch64_available(void) return "Using ARMv8 crc32 instructions"; } +#endif /* __APPLE__ */ #endif /* HAVE_ARMV8_CRC */ #ifndef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS