From: David CARLIER Date: Thu, 31 Dec 2020 14:52:57 +0000 (+0000) Subject: Mac M1 crc32 detection support X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e90c7550759508b394cb15f34699a12ffa61318;p=php Mac M1 crc32 detection support Closes GH-6556. --- 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;