php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch check-cpuid-count for Compile Failure Bug #76825

Patch version 2018-10-17 11:59 UTC

Return to Bug #76825 | Download this patch
Patch Revisions:

Developer: cmb@php.net

 Zend/Zend.m4        | 18 ++++++++++++++++++
 Zend/zend_cpuinfo.c |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
index 06563c7b77..17670014f7 100644
--- a/Zend/Zend.m4
+++ b/Zend/Zend.m4
@@ -491,3 +491,21 @@ dnl This is the most probable fallback so we assume yes in case of cross compile
 if test "$ac_cv_huge_val_nan" = "yes"; then
   AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN])
 fi
+
+dnl
+dnl Check whether __cpuid_count is available
+dnl
+AC_CACHE_CHECK(whether __cpuid_count is available, ac_cv_cpuid_count_available, [
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+  #include <cpuid.h>
+]], [[
+  unsigned eax, ebx, ecx, edx;
+  __cpuid_count(0, 0, eax, ebx, ecx, edx);
+]])], [
+  ac_cv_cpuid_count_available=yes
+], [
+  ac_cv_cpuid_count_available=no
+])])
+if test "$ac_cv_cpuid_count_available" = "yes"; then
+  AC_DEFINE([HAVE_CPUID_COUNT], 1, [whether __cpuid_count is available])
+fi
diff --git a/Zend/zend_cpuinfo.c b/Zend/zend_cpuinfo.c
index ffa370416d..5791a11c62 100644
--- a/Zend/zend_cpuinfo.c
+++ b/Zend/zend_cpuinfo.c
@@ -29,7 +29,7 @@ typedef struct _zend_cpu_info {
 static zend_cpu_info cpuinfo = {0};
 
 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-# ifdef HAVE_CPUID_H
+# if defined(HAVE_CPUID_H) && defined(HAVE_CPUID_COUNT)
 # include <cpuid.h>
 static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) {
 	__cpuid_count(func, subfunc, cpuinfo->eax, cpuinfo->ebx, cpuinfo->ecx, cpuinfo->edx);
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jul 04 19:01:16 2020 UTC