/dev-util/stressapptest/files/stressapptest-1.0.4-cpuid-pic.patch
Patch | 43 lines | 41 code | 2 blank | 0 comment | 0 complexity | 737bf76f76b601f69d8e0d48db5e304e MD5 | raw file
- 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;