Skip to content

Commit 4fb0199

Browse files
committed
Fix __zend_cpuid on i386 PIC without __cpuid_count
Closes https://bugs.php.net/bug.php?id=76654
1 parent cb3a1df commit 4fb0199

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Zend/zend_cpuinfo.c

+12
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,23 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo
3636
}
3737
# else
3838
static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) {
39+
#if defined(__i386__) && (defined(__pic__) || defined(__PIC__))
40+
/* PIC on i386 uses %ebx, so preserve it. */
41+
__asm__ __volatile__ (
42+
"pushl %%ebx\n"
43+
"cpuid\n"
44+
"mov %%ebx,%1\n"
45+
"popl %%ebx"
46+
: "=a"(cpuinfo->eax), "=r"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx)
47+
: "a"(func), "c"(subfunc)
48+
);
49+
#else
3950
__asm__ __volatile__ (
4051
"cpuid"
4152
: "=a"(cpuinfo->eax), "=b"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx)
4253
: "a"(func), "c"(subfunc)
4354
);
55+
#endif
4456
}
4557
# endif
4658
#elif defined(ZEND_WIN32) && !defined(__clang__)

0 commit comments

Comments
 (0)