diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-08-30 13:50:36 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-08-30 13:52:27 +0300 |
commit | 8c3d2e549cff4d9c369c68936e0fce6b7ddc495f (patch) | |
tree | 789c6fbc6ffd099051b4d8d8ccec9483de827ed8 /intern/cycles/util/util_system.cpp | |
parent | 49041e5611bd3974976c9cceec8d2f81cd5a1d9b (diff) |
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.
Diffstat (limited to 'intern/cycles/util/util_system.cpp')
-rw-r--r-- | intern/cycles/util/util_system.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index 2428b0b2989..1b039888452 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -107,25 +107,26 @@ unsigned short system_cpu_process_groups(unsigned short max_groups, #if !defined(_WIN32) || defined(FREE_WINDOWS) 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)); -#else -#ifdef __i386__ +#elif defined(__i386__) asm("pushl %%ebx \n\t" - "cpuid \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)); + "cpuid \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) + : "ebx"); #else data[0] = data[1] = data[2] = data[3] = 0; #endif -#endif } #endif string system_cpu_brand_string() { - char buf[48]; - int result[4]; + char buf[48] = {0}; + int result[4] = {0}; __cpuid(result, 0x80000000); |