[Bf-blender-cvs] [8c3d2e549cf] master: Cycles: Fix detection of CPU brand string on 32 bit platforms

Sergey Sharybin noreply at git.blender.org
Thu Aug 30 12:52:30 CEST 2018


Commit: 8c3d2e549cff4d9c369c68936e0fce6b7ddc495f
Author: Sergey Sharybin
Date:   Thu Aug 30 12:50:36 2018 +0200
Branches: master
https://developer.blender.org/rB8c3d2e549cff4d9c369c68936e0fce6b7ddc495f

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.

===================================================================

M	intern/cycles/util/util_system.cpp

===================================================================

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);



More information about the Bf-blender-cvs mailing list