blob: 740349bc6f1fcec8981ad93fa3d156aa5bc74e2f [file] [log] [blame]
http://code.google.com/p/stressapptest/issues/detail?id=26
--- a/src/os.cc
+++ b/src/os.cc
@@ -149,7 +149,16 @@ void OsLayer::GetFeatures() {
// http://www.sandpile.org/ia32/cpuid.htm
int ax, bx, cx, dx;
__asm__ __volatile__ (
- "cpuid": "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (1));
+# if defined(STRESSAPPTEST_CPU_I686) && defined(__PIC__)
+ "xchg %%ebx, %%esi;"
+ "cpuid;"
+ "xchg %%esi, %%ebx;"
+ : "=S" (bx),
+# else
+ "cpuid;"
+ : "=b" (bx),
+# endif
+ "=a" (ax), "=c" (cx), "=d" (dx) : "a" (1));
has_clflush_ = (dx >> 19) & 1;
has_sse2_ = (dx >> 26) & 1;
--- a/src/worker.cc
+++ b/src/worker.cc
@@ -85,7 +85,17 @@ namespace {
inline int apicid(void) {
int cpu;
#if defined(STRESSAPPTEST_CPU_X86_64) || defined(STRESSAPPTEST_CPU_I686)
- __asm __volatile("cpuid" : "=b" (cpu) : "a" (1) : "cx", "dx");
+ __asm__ __volatile__ (
+# if defined(STRESSAPPTEST_CPU_I686) && defined(__PIC__)
+ "xchg %%ebx, %%esi;"
+ "cpuid;"
+ "xchg %%esi, %%ebx;"
+ : "=S" (cpu)
+# else
+ "cpuid;"
+ : "=b" (cpu)
+# endif
+ : "a" (1) : "cx", "dx");
#elif defined(STRESSAPPTEST_CPU_ARMV7A)
#warning "Unsupported CPU type ARMV7A: unable to determine core ID."
cpu = 0;