Cycles: Fix detection of CPU brand string on 32 bit platforms

The assembler template was backing up and restoring ebx, which is
fair enough. However, this did not prevent compiler for putting
result variables to ebx. This was causing data corruption.

In order to prevent this easiest solution is to list ebx in clobbers
for the assembly.
This commit is contained in:
Sergey Sharybin 2018-08-30 12:50:36 +02:00
parent 49041e5611
commit 8c3d2e549c

@ -107,25 +107,26 @@ unsigned short system_cpu_process_groups(unsigned short max_groups,
#if !defined(_WIN32) || defined(FREE_WINDOWS) #if !defined(_WIN32) || defined(FREE_WINDOWS)
static void __cpuid(int data[4], int selector) static void __cpuid(int data[4], int selector)
{ {
#ifdef __x86_64__ #if defined(__x86_64__)
asm("cpuid" : "=a" (data[0]), "=b" (data[1]), "=c" (data[2]), "=d" (data[3]) : "a"(selector)); asm("cpuid" : "=a" (data[0]), "=b" (data[1]), "=c" (data[2]), "=d" (data[3]) : "a"(selector));
#else #elif defined(__i386__)
#ifdef __i386__
asm("pushl %%ebx \n\t" asm("pushl %%ebx \n\t"
"cpuid \n\t" "cpuid \n\t"
"movl %%ebx, %1 \n\t" "movl %%ebx, %1 \n\t"
"popl %%ebx \n\t" : "=a" (data[0]), "=r" (data[1]), "=c" (data[2]), "=d" (data[3]) : "a"(selector)); "popl %%ebx \n\t"
: "=a" (data[0]), "=r" (data[1]), "=c" (data[2]), "=d" (data[3])
: "a"(selector)
: "ebx");
#else #else
data[0] = data[1] = data[2] = data[3] = 0; data[0] = data[1] = data[2] = data[3] = 0;
#endif #endif
#endif
} }
#endif #endif
string system_cpu_brand_string() string system_cpu_brand_string()
{ {
char buf[48]; char buf[48] = {0};
int result[4]; int result[4] = {0};
__cpuid(result, 0x80000000); __cpuid(result, 0x80000000);