diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-01-16 13:51:50 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-01-16 13:51:50 +0300 |
commit | 1fd651650fb4821054decac5a0664f88fe4e55c3 (patch) | |
tree | 236306873858e179c11db3223d1b60565d2dda2f /Zend/zend_cpuinfo.c | |
parent | 0bfc4f34caabc31a83a130af43820d369b29e800 (diff) | |
parent | 811326089fcc2e629fcfcf6365342835fb362121 (diff) | |
download | php-git-1fd651650fb4821054decac5a0664f88fe4e55c3.tar.gz |
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src:
Separate the cpuinfo initialization part and call it at startup
Diffstat (limited to 'Zend/zend_cpuinfo.c')
-rw-r--r-- | Zend/zend_cpuinfo.c | 10 |
1 files changed, 7 insertions, 3 deletions
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 { |