Skip to content

Commit df717a9

Browse files
committed
Properly detect CRC32 APIs on aarch64 from configure.
The CRC32 APIs are optional for armv8-a. They became mandatory since armv8.1-a.
1 parent 7d66e4f commit df717a9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,12 @@ if test "x$php_crypt_r" = "x1"; then
668668
PHP_CRYPT_R_STYLE
669669
fi
670670

671+
php_aarch64_crc32="1"
672+
AC_CHECK_FUNCS([__crc32d __crc32w __crc32h __crc32b], [], [ php_aarch64_crc32="0" ])
673+
if test "x$php_aarch64_crc32" = "x1"; then
674+
AC_DEFINE([HAVE_AARCH64_CRC32], [1], [Define when aarch64 CRC32 API is available.])
675+
fi
676+
671677
dnl Check for asm goto support.
672678
AC_CACHE_CHECK([for asm goto], ac_cv__asm_goto,
673679
[AC_RUN_IFELSE([AC_LANG_SOURCE([[

ext/standard/crc32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "basic_functions.h"
1919
#include "crc32.h"
2020

21-
#if defined(__aarch64__) && defined(HAVE_SYS_AUXV_H)
21+
#if HAVE_AARCH64_CRC32
2222
# include <arm_acle.h>
2323
# if defined(__linux__)
2424
# include <sys/auxv.h>
@@ -83,7 +83,7 @@ PHP_FUNCTION(crc32)
8383

8484
crc = crcinit^0xFFFFFFFF;
8585

86-
#if defined(__aarch64__) && defined(HAVE_SYS_AUXV_H)
86+
#if HAVE_AARCH64_CRC32
8787
if (has_crc32_insn()) {
8888
crc = crc32_aarch64(crc, p, nr);
8989
RETURN_LONG(crc^0xFFFFFFFF);

0 commit comments

Comments
 (0)