Properly detect CRC32 APIs on aarch64 from configure
authorOndřej Surý <ondrej@sury.org>
Wed, 13 May 2020 06:22:29 +0000 (08:22 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 14 May 2020 07:38:05 +0000 (09:38 +0200)
The CRC32 APIs are optional for armv8-a. They became mandatory since
armv8.1-a.

Closes GH-5564.

configure.ac
ext/standard/crc32.c

index fdf35e213b41c3dd3045ea38fb66397f8d8d534e..c589896741fc18d80dbe0f85d5f56240f18f22b3 100644 (file)
@@ -720,6 +720,12 @@ if test "x$php_crypt_r" = "x1"; then
   PHP_CRYPT_R_STYLE
 fi
 
+AC_CACHE_CHECK([for aarch64 CRC32 API], ac_cv_func___crc32d,
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <arm_acle.h>]],[[__crc32d(0, 0);]])],[ac_cv_func___crc32d=yes],[ac_cv_func___crc32d="no"])])
+if test "$ac_cv_func___crc32d" = "yes"; then
+  AC_DEFINE([HAVE_AARCH64_CRC32], [1], [Define when aarch64 CRC32 API is available.])
+fi
+
 dnl Check for asm goto support.
 AC_CACHE_CHECK([for asm goto], ac_cv__asm_goto,
 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
index 765135a142e7a91c384c0f3d0623466e22d7fbe5..497b1336422c9b67adf05134c92fd834461a663b 100644 (file)
@@ -20,7 +20,7 @@
 #include "basic_functions.h"
 #include "crc32.h"
 
-#if defined(__aarch64__) && defined(HAVE_SYS_AUXV_H)
+#if HAVE_AARCH64_CRC32
 # include <arm_acle.h>
 # if defined(__linux__)
 #  include <sys/auxv.h>
@@ -85,7 +85,7 @@ PHP_NAMED_FUNCTION(php_if_crc32)
 
        crc = crcinit^0xFFFFFFFF;
 
-#if defined(__aarch64__) && defined(HAVE_SYS_AUXV_H)
+#if HAVE_AARCH64_CRC32
        if (has_crc32_insn()) {
                crc = crc32_aarch64(crc, p, nr);
                RETURN_LONG(crc^0xFFFFFFFF);