aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2011-07-26 19:28:31 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2011-07-29 19:31:53 +0200
commit9085ce6f615d9d2e0182d3ce029b882835bd0a6b (patch)
treed22ccabaaacefee8a87a2f46101c09078a6e0791
parent9f2efa7bc6969c10562ac2c720d50ff77083e5c2 (diff)
downloadcpufrequtils-9085ce6f615d9d2e0182d3ce029b882835bd0a6b.tar.gz
aperf: fix compilation on x86-32 with -fPIC
ebx is used to store the GOT pointer when compiled with -fPIC, so it's not usable by inline assembly. https://bugs.gentoo.org/375967 Signed-off-by: Matt Turner <mattst88@gmail.com> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
-rw-r--r--utils/cpuid.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/utils/cpuid.h b/utils/cpuid.h
index 2bac69a..53da789 100644
--- a/utils/cpuid.h
+++ b/utils/cpuid.h
@@ -5,9 +5,21 @@ static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
/* ecx is often an input as well as an output. */
- asm volatile("cpuid"
+ asm volatile(
+#if defined(__i386__) && defined(__PIC__)
+ "push %%ebx\n"
+ "cpuid\n"
+ "movl %%ebx, %1\n"
+ "pop %%ebx\n"
+#else
+ "cpuid\n"
+#endif
: "=a" (*eax),
+#if defined(__i386__) && defined(__PIC__)
+ "=r" (*ebx),
+#else
"=b" (*ebx),
+#endif
"=c" (*ecx),
"=d" (*edx)
: "0" (*eax), "2" (*ecx));