PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/dev-util/stressapptest/files/stressapptest-1.0.4-cpuid-pic.patch

https://gitlab.com/rindeal/gentoo-cvs-history-archive
Patch | 43 lines | 41 code | 2 blank | 0 comment | 0 complexity | 737bf76f76b601f69d8e0d48db5e304e MD5 | raw file
  1. http://code.google.com/p/stressapptest/issues/detail?id=26
  2. --- a/src/os.cc
  3. +++ b/src/os.cc
  4. @@ -149,7 +149,16 @@ void OsLayer::GetFeatures() {
  5. // http://www.sandpile.org/ia32/cpuid.htm
  6. int ax, bx, cx, dx;
  7. __asm__ __volatile__ (
  8. - "cpuid": "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (1));
  9. +# if defined(STRESSAPPTEST_CPU_I686) && defined(__PIC__)
  10. + "xchg %%ebx, %%esi;"
  11. + "cpuid;"
  12. + "xchg %%esi, %%ebx;"
  13. + : "=S" (bx),
  14. +# else
  15. + "cpuid;"
  16. + : "=b" (bx),
  17. +# endif
  18. + "=a" (ax), "=c" (cx), "=d" (dx) : "a" (1));
  19. has_clflush_ = (dx >> 19) & 1;
  20. has_sse2_ = (dx >> 26) & 1;
  21. --- a/src/worker.cc
  22. +++ b/src/worker.cc
  23. @@ -85,7 +85,17 @@ namespace {
  24. inline int apicid(void) {
  25. int cpu;
  26. #if defined(STRESSAPPTEST_CPU_X86_64) || defined(STRESSAPPTEST_CPU_I686)
  27. - __asm __volatile("cpuid" : "=b" (cpu) : "a" (1) : "cx", "dx");
  28. + __asm__ __volatile__ (
  29. +# if defined(STRESSAPPTEST_CPU_I686) && defined(__PIC__)
  30. + "xchg %%ebx, %%esi;"
  31. + "cpuid;"
  32. + "xchg %%esi, %%ebx;"
  33. + : "=S" (cpu)
  34. +# else
  35. + "cpuid;"
  36. + : "=b" (cpu)
  37. +# endif
  38. + : "a" (1) : "cx", "dx");
  39. #elif defined(STRESSAPPTEST_CPU_ARMV7A)
  40. #warning "Unsupported CPU type ARMV7A: unable to determine core ID."
  41. cpu = 0;