diff options
author | David CARLIER <devnexen@gmail.com> | 2020-12-31 18:37:01 +0000 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2022-08-25 20:32:59 -0700 |
commit | ed110bb0db938810d8fdb9d4e4b2fef9ab0bf5ac (patch) | |
tree | 57eba468d67db272c8433d7cd3aa61c555d82faf /crc32c.c | |
parent | 2d5dd8d9e12daccaa303601725d742612ec3a8eb (diff) | |
download | memcached-ed110bb0db938810d8fdb9d4e4b2fef9ab0bf5ac.tar.gz |
Mac M1 build update.
detects arm64 crc32 h/w support.
Diffstat (limited to 'crc32c.c')
-rw-r--r-- | crc32c.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -273,8 +273,12 @@ void crc32c_init(void) { } } -#elif defined(__aarch64__) && defined(__linux__) +#elif defined(__aarch64__) && (defined(__linux__) || defined(__APPLE__)) +#if defined(__linux__) #include <sys/auxv.h> +#elif defined(__APPLE__) +#include <sys/sysctl.h> +#endif #if defined(HWCAP_CRC32) static inline uint32_t crc32cx(uint32_t crc, const uint64_t data) @@ -331,11 +335,20 @@ static uint32_t crc32c_hw(uint32_t crc, void const *buf, size_t len) { } void crc32c_init(void) { +#if defined(__linux__) uint64_t auxv = getauxval(AT_HWCAP); crc32c = crc32c_sw; if (auxv & HWCAP_CRC32) crc32c = crc32c_hw; +#elif defined(__APPLE__) + int armv8_crc32; + size_t size = sizeof(armv8_crc32); + + if (sysctlbyname("hw.optional.armv8_crc32", &armv8_crc32, &size, NULL, 0) == 0 && + armv8_crc32 == 1) + crc32c = crc32c_hw; +#endif } #else /* no hw crc32 on arm64 system supported? old compiler/libc/kernel? */ void crc32c_init(void) { |