From 6e90c7550759508b394cb15f34699a12ffa61318 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Thu, 31 Dec 2020 14:52:57 +0000 Subject: [PATCH] Mac M1 crc32 detection support Closes GH-6556. --- ext/standard/crc32.c | 6 ++++++ 1 file changed, 6 insertions(+) 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 # 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; -- 2.50.1