summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-01-16 11:27:18 +0100
committerAnatol Belski <ab@php.net>2018-01-16 11:27:18 +0100
commit811326089fcc2e629fcfcf6365342835fb362121 (patch)
treed6a34782dbd8f8ee376265c89ff5550a2fab3ae3 /Zend
parent560cc32e21455b8320c1bd038b5ced3c26676f5e (diff)
downloadphp-git-811326089fcc2e629fcfcf6365342835fb362121.tar.gz
Separate the cpuinfo initialization part and call it at startup
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend.c3
-rw-r--r--Zend/zend_cpuinfo.c10
-rw-r--r--Zend/zend_cpuinfo.h2
3 files changed, 12 insertions, 3 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index 4a5fc749b7..effc95deb2 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -33,6 +33,7 @@
#include "zend_virtual_cwd.h"
#include "zend_smart_str.h"
#include "zend_smart_string.h"
+#include "zend_cpuinfo.h"
#ifdef ZTS
ZEND_API int compiler_globals_id;
@@ -752,6 +753,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) /
extern zend_php_scanner_globals language_scanner_globals;
#endif
+ zend_cpu_startup();
+
#ifdef ZEND_WIN32
php_win32_cp_set_by_id(65001);
#endif
diff --git a/Zend/zend_cpuinfo.c b/Zend/zend_cpuinfo.c
index 26f3338f3d..ce92460fb4 100644
--- a/Zend/zend_cpuinfo.c
+++ b/Zend/zend_cpuinfo.c
@@ -27,7 +27,7 @@ typedef struct _zend_cpu_info {
uint32_t initialized;
} zend_cpu_info;
-static zend_cpu_info cpuinfo;
+static zend_cpu_info cpuinfo = {0};
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
static void __zend_cpuid(uint32_t func, uint32_t subfunc) {
@@ -55,15 +55,19 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc) {
}
#endif
-ZEND_API int zend_cpu_supports(zend_cpu_feature feature) {
+void zend_cpu_startup(void)
+{
if (!cpuinfo.initialized) {
cpuinfo.initialized = 1;
__zend_cpuid(0, 0);
if (cpuinfo.eax == 0) {
- return 0;
+ return;
}
__zend_cpuid(1, 0);
}
+}
+
+ZEND_API int zend_cpu_supports(zend_cpu_feature feature) {
if (feature & ZEND_CPU_EDX_MASK) {
return (cpuinfo.edx & (feature & ~ZEND_CPU_EDX_MASK));
} else {
diff --git a/Zend/zend_cpuinfo.h b/Zend/zend_cpuinfo.h
index e44938fd98..97e33a55cc 100644
--- a/Zend/zend_cpuinfo.h
+++ b/Zend/zend_cpuinfo.h
@@ -93,6 +93,8 @@ typedef enum _zend_cpu_feature {
ZEND_API int zend_cpu_supports(zend_cpu_feature feature);
+void zend_cpu_startup(void);
+
#endif
/*