summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorMike Frysinger2009-05-10 22:37:18 +0200
committerKarel Zak2009-05-11 10:52:02 +0200
commitc9239f23acdc8b50f8bcbfadf967c6a490fd4693 (patch)
tree918cd73cf6e1c5acf29f9ce8741644f394fcf3bb /sys-utils/lscpu.c
parentchrt: don't assume SCHED_BATCH and SCHED_IDLE exist (diff)
downloadkernel-qcow2-util-linux-c9239f23acdc8b50f8bcbfadf967c6a490fd4693.tar.gz
kernel-qcow2-util-linux-c9239f23acdc8b50f8bcbfadf967c6a490fd4693.tar.xz
kernel-qcow2-util-linux-c9239f23acdc8b50f8bcbfadf967c6a490fd4693.zip
lscpu: fix cpuid code on x86/PIC
If we build lscpu as PIE, we currently get a build failure: lscpu.c: In function 'main': lscpu.c:333: error: can't find a register in class 'BREG' while reloading 'asm' lscpu.c:333: error: 'asm' operand has impossible constraints make[2]: *** [lscpu.o] Error 1 So we need a little bit of register shuffling to keep gcc happy. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 3e3fbbeb6..6b6082fbf 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -330,9 +330,19 @@ static inline void
cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
- __asm__("cpuid"
- : "=a" (*eax),
- "=b" (*ebx),
+ __asm__(
+#if defined(__PIC__) && defined(__i386__)
+ /* x86 PIC cannot clobber ebx -- gcc bitches */
+ "pushl %%ebx;"
+ "cpuid;"
+ "movl %%ebx, %%esi;"
+ "popl %%ebx;"
+ : "=S" (*ebx),
+#else
+ "cpuid;"
+ : "=b" (*ebx),
+#endif
+ "=a" (*eax),
"=c" (*ecx),
"=d" (*edx)
: "0" (op), "c"(0));