Skip to content

Commit f91ece0

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Mac M1 crc32 detection support
2 parents faeca51 + 6e90c75 commit f91ece0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ext/standard/crc32.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
# if defined(__linux__)
2525
# include <sys/auxv.h>
2626
# include <asm/hwcap.h>
27+
# elif defined(__APPLE__)
28+
# include <sys/sysctl.h>
2729
# endif
2830

2931
static inline int has_crc32_insn() {
@@ -37,6 +39,10 @@ static inline int has_crc32_insn() {
3739
# elif defined(HWCAP2_CRC32)
3840
res = getauxval(AT_HWCAP2) & HWCAP2_CRC32;
3941
return res;
42+
# elif defined(__APPLE__)
43+
size_t reslen = sizeof(res);
44+
if (sysctlbyname("hw.optional.armv8_crc32", &res, &reslen, NULL, 0) < 0)
45+
res = 0;
4046
# else
4147
res = 0;
4248
return res;

0 commit comments

Comments
 (0)