diff options
author | Ryan Schmidt <git@ryandesign.com> | 2018-12-08 09:52:52 -0600 |
---|---|---|
committer | Ryan Schmidt <git@ryandesign.com> | 2018-12-08 09:52:52 -0600 |
commit | 4fb019994a8420a7989f05b38ee8249ea12541b1 (patch) | |
tree | a0067787fb7a47550d70ecc2fe6f2045decad1b4 | |
parent | cb3a1df94668a740548ca1dcaa062d949356be71 (diff) | |
download | php-git-4fb019994a8420a7989f05b38ee8249ea12541b1.tar.gz |
Fix __zend_cpuid on i386 PIC without __cpuid_count
Closes https://bugs.php.net/bug.php?id=76654
-rw-r--r-- | Zend/zend_cpuinfo.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Zend/zend_cpuinfo.c b/Zend/zend_cpuinfo.c index 5791a11c62..ea1f08f948 100644 --- a/Zend/zend_cpuinfo.c +++ b/Zend/zend_cpuinfo.c @@ -36,11 +36,23 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo } # else static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) { +#if defined(__i386__) && (defined(__pic__) || defined(__PIC__)) + /* PIC on i386 uses %ebx, so preserve it. */ + __asm__ __volatile__ ( + "pushl %%ebx\n" + "cpuid\n" + "mov %%ebx,%1\n" + "popl %%ebx" + : "=a"(cpuinfo->eax), "=r"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx) + : "a"(func), "c"(subfunc) + ); +#else __asm__ __volatile__ ( "cpuid" : "=a"(cpuinfo->eax), "=b"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx) : "a"(func), "c"(subfunc) ); +#endif } # endif #elif defined(ZEND_WIN32) && !defined(__clang__) |