summaryrefslogtreecommitdiff
path: root/ext/standard/crc32.c
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2020-12-31 14:52:57 +0000
committerNikita Popov <nikita.ppv@gmail.com>2021-01-04 11:41:52 +0100
commit6e90c7550759508b394cb15f34699a12ffa61318 (patch)
treee4ec376159aa3108a5da8d6334e0e71ad634b4d6 /ext/standard/crc32.c
parent151fce1129dd08e16375b2fe16474db448c228c2 (diff)
downloadphp-git-6e90c7550759508b394cb15f34699a12ffa61318.tar.gz
Mac M1 crc32 detection support
Closes GH-6556.
Diffstat (limited to 'ext/standard/crc32.c')
-rw-r--r--ext/standard/crc32.c6
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;