Skip to content

Commit d4bebc8

Browse files
oerdnjnikic
authored andcommitted
Properly detect CRC32 APIs on aarch64 from configure
The CRC32 APIs are optional for armv8-a. They became mandatory since armv8.1-a. Closes phpGH-5564.
1 parent 1892e3a commit d4bebc8

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
@@ -720,6 +720,12 @@ if test "x$php_crypt_r" = "x1"; then
720720
PHP_CRYPT_R_STYLE
721721
fi
722722

723+
AC_CACHE_CHECK([for aarch64 CRC32 API], ac_cv_func___crc32d,
724+
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <arm_acle.h>]],[[__crc32d(0, 0);]])],[ac_cv_func___crc32d=yes],[ac_cv_func___crc32d="no"])])
725+
if test "$ac_cv_func___crc32d" = "yes"; then
726+
AC_DEFINE([HAVE_AARCH64_CRC32], [1], [Define when aarch64 CRC32 API is available.])
727+
fi
728+
723729
dnl Check for asm goto support.
724730
AC_CACHE_CHECK([for asm goto], ac_cv__asm_goto,
725731
[AC_RUN_IFELSE([AC_LANG_SOURCE([[

ext/standard/crc32.c

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

23-
#if defined(__aarch64__) && defined(HAVE_SYS_AUXV_H)
23+
#if HAVE_AARCH64_CRC32
2424
# include <arm_acle.h>
2525
# if defined(__linux__)
2626
# include <sys/auxv.h>
@@ -85,7 +85,7 @@ PHP_NAMED_FUNCTION(php_if_crc32)
8585

8686
crc = crcinit^0xFFFFFFFF;
8787

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

0 commit comments

Comments
 (0)