diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c index 40d9404053e..83f4314b694 100644 --- a/ext/standard/crc32.c +++ b/ext/standard/crc32.c @@ -24,6 +24,8 @@ # if defined(__linux__) # include # include +# elif defined(__APPLE__) +# include # endif static inline int has_crc32_insn() { @@ -37,6 +39,10 @@ static inline int has_crc32_insn() { # elif defined(HWCAP2_CRC32) res = getauxval(AT_HWCAP2) & HWCAP2_CRC32; return res; +# elif defined(__APPLE__) + size_t reslen = sizeof(res); + if (sysctlbyname("hw.optional.armv8_crc32", &res, &reslen, NULL, 0) < 0) + res = 0; # else res = 0; return res;