blob: 6288846b48b7ce6f74fe36bdc521dbb7b25191ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
--- a/cpuid.c
+++ b/cpuid.c
@@ -25,12 +25,28 @@
bind_cpu(cpunr);
+#ifdef __PIC__
+ /* GCC on i386 bitches if you clobber ebx. So hide it behind
+ * gcc's back. */
+ asm(
+ "movl %%ebx,%%edi\n"
+ "cpuid\n"
+ "movl %%ebx,%1\n"
+ "movl %%edi,%%ebx\n"
+ : "=a" (a),
+ "=m" (b),
+ "+c" (c),
+ "=d" (d)
+ : "0" ((unsigned int)idx)
+ : "edi");
+#else
asm("cpuid"
: "=a" (a),
"=b" (b),
"+c" (c),
"=d" (d)
: "0" ((unsigned int)idx));
+#endif
if (eax!=NULL)
*eax = a;
|