diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/standard/crc32.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c index 40d9404053..83f4314b69 100644 --- a/ext/standard/crc32.c +++ b/ext/standard/crc32.c @@ -24,6 +24,8 @@ # if defined(__linux__) # include <sys/auxv.h> # include <asm/hwcap.h> +# elif defined(__APPLE__) +# include <sys/sysctl.h> # 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; |