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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
--- gimp-2.0pre2/app/base/cpu-accel.c 2003-09-07 15:56:51.000000000 -0400
+++ gimp-cvs/app/base/cpu-accel.c 2004-01-31 04:01:34.000000000 -0500
@@ -40,11 +40,6 @@
#ifdef ARCH_X86
-#if GLIB_SIZEOF_LONG == 8
-#define ARCH_X86_64 1
-#endif
-
-
typedef enum
{
ARCH_X86_VENDOR_NONE,
@@ -78,14 +73,25 @@
ARCH_X86_CYRIX_FEATURE_MMXEXT = 1 << 24
};
-/* FIXME: This should save off ebx/rbx if compiled for PIC */
-#define cpuid(op,eax,ebx,ecx,edx) \
- asm ("cpuid\n\t" \
- : "=a" (eax), \
- "=b" (ebx), \
- "=c" (ecx), \
- "=d" (edx) \
- : "0" (op))
+#if !defined(ARCH_X86_64) && (defined(__PIC__) || defined(__pic__) || defined(PIC))
+#define cpuid(op,eax,ebx,ecx,edx) \
+ __asm__ ("movl %%ebx, %%esi\n\t" \
+ "cpuid\n\t" \
+ "xchgl %%ebx,%%esi" \
+ : "=a" (eax), \
+ "=S" (ebx), \
+ "=c" (ecx), \
+ "=d" (edx) \
+ : "0" (op))
+#else
+#define cpuid(op,eax,ebx,ecx,edx) \
+ __asm__ ("cpuid" \
+ : "=a" (eax), \
+ "=b" (ebx), \
+ "=c" (ecx), \
+ "=d" (edx) \
+ : "0" (op))
+#endif
static X86Vendor
@@ -96,22 +102,22 @@
#ifndef ARCH_X86_64
/* Only need to check this on ia32 */
- asm ("pushfl\n\t"
- "pushfl\n\t"
- "popl %0\n\t"
- "movl %0,%1\n\t"
- "xorl $0x200000,%0\n\t"
- "push %0\n\t"
- "popfl\n\t"
- "pushfl\n\t"
- "popl %0\n\t"
- "popfl\n\t"
- : "=a" (eax),
- "=b" (ebx)
- :
- : "cc");
+ __asm__ ("pushfl\n\t"
+ "pushfl\n\t"
+ "popl %0\n\t"
+ "movl %0,%1\n\t"
+ "xorl $0x200000,%0\n\t"
+ "pushl %0\n\t"
+ "popfl\n\t"
+ "pushfl\n\t"
+ "popl %0\n\t"
+ "popfl"
+ : "=a" (eax),
+ "=c" (ecx)
+ :
+ : "cc");
- if (eax == ebx)
+ if (eax == ecx)
return ARCH_X86_VENDOR_NONE;
#endif
@@ -385,7 +391,6 @@
accel = arch_accel ();
#ifdef USE_SSE
-
/* test OS support for SSE */
if (accel & CPU_ACCEL_X86_SSE)
{
@@ -396,7 +401,7 @@
else
{
signal (SIGILL, sigill_handler);
- __asm __volatile ("xorps %xmm0, %xmm0");
+ __asm__ __volatile__ ("xorps %xmm0, %xmm0");
signal (SIGILL, SIG_DFL);
}
}
|