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
32
33
34
35
36
37
38
39
40
41
42
43
|
The 'cpuid' assembly instruction is notorious for hating PIC.
Here we code two different versions of the cpuid instruction ...
the first will work when dealing with PIC, while the second is
slightly faster and can be used with non-PIC.
http://bugs.gentoo.org/61947
--- src/core/cpuid.cc
+++ src/core/cpuid.cc
@@ -68,9 +68,6 @@
#ifdef __i386__
-#define cpuid_up(in,a,b,c,d)\
- asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in));
-
static void cpuid(int cpunumber,
unsigned long idx,
unsigned long &eax,
@@ -96,7 +93,21 @@
edx = (*(unsigned long *) (buffer + 12));
}
else
- cpuid_up(idx, eax, ebx, ecx, edx);
+ asm(
+#ifdef __PIC__
+ "movl %%ebx,%%edi\n"
+ "cpuid\n"
+ "movl %%ebx,%3\n"
+ "movl %%edi,%%ebx\n"
+ : "=a" (eax), "=c" (ecx), "=d" (edx), "=m" (ebx)
+ : "a" (idx)
+ : "edi"
+#else
+ "cpuid\n"
+ : "=a" (eax), "=c" (ecx), "=d" (edx), "=b" (ebx)
+ : "a" (idx)
+#endif
+ );
}
/* Decode Intel TLB and cache info descriptors */
|