1 Subject: Patches needed to build on SLE11/11.1 |
|
2 References: |
|
3 https://bugzilla.mozilla.org/show_bug.cgi?id=513422 |
|
4 |
|
5 diff --git a/mozglue/build/SSE.cpp b/mozglue/build/SSE.cpp |
|
6 --- a/mozglue/build/SSE.cpp |
|
7 +++ b/mozglue/build/SSE.cpp |
|
8 @@ -12,26 +12,77 @@ namespace { |
|
9 // SSE.h has parallel #ifs which declare MOZILLA_SSE_HAVE_CPUID_DETECTION. |
|
10 // We can't declare these functions in the header file, however, because |
|
11 // <intrin.h> conflicts with <windows.h> on MSVC 2005, and some files want to |
|
12 // include both SSE.h and <windows.h>. |
|
13 |
|
14 #ifdef HAVE_CPUID_H |
|
15 |
|
16 // cpuid.h is available on gcc 4.3 and higher on i386 and x86_64 |
|
17 -#include <cpuid.h> |
|
18 +//#include <cpuid.h> |
|
19 |
|
20 enum CPUIDRegister { eax = 0, ebx = 1, ecx = 2, edx = 3 }; |
|
21 |
|
22 +#ifdef __i386__ |
|
23 +#define _my_cpuid(level, a, b, c, d) \ |
|
24 + __asm__ ("xchg{l}\t{%%}ebx, %1\n\t" \ |
|
25 + "cpuid\n\t" \ |
|
26 + "xchg{l}\t{%%}ebx, %1\n\t" \ |
|
27 + : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ |
|
28 + : "0" (level)) |
|
29 +#else |
|
30 +#define _my_cpuid(level, a, b, c, d) \ |
|
31 + __asm__ ("cpuid\n\t" \ |
|
32 + : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ |
|
33 + : "0" (level)) |
|
34 +#endif |
|
35 + |
|
36 +static __inline unsigned int |
|
37 +my_cpuid_max (unsigned int __ext, unsigned int *__sig) |
|
38 +{ |
|
39 + unsigned int __eax, __ebx, __ecx, __edx; |
|
40 + |
|
41 +#ifdef __i386__ |
|
42 + __asm__ ("pushf{l|d}\n\t" |
|
43 + "pushf{l|d}\n\t" |
|
44 + "pop{l}\t%0\n\t" |
|
45 + "mov{l}\t{%0, %1|%1, %0}\n\t" |
|
46 + "xor{l}\t{%2, %0|%0, %2}\n\t" |
|
47 + "push{l}\t%0\n\t" |
|
48 + "popf{l|d}\n\t" |
|
49 + "pushf{l|d}\n\t" |
|
50 + "pop{l}\t%0\n\t" |
|
51 + "popf{l|d}\n\t" |
|
52 + : "=&r" (__eax), "=&r" (__ebx) |
|
53 + : "i" (0x00200000)); |
|
54 + |
|
55 + if (!((__eax ^ __ebx) & 0x00200000)) |
|
56 + return 0; |
|
57 +#endif |
|
58 + |
|
59 + /* Host supports cpuid. Return highest supported cpuid input value. */ |
|
60 + _my_cpuid (__ext, __eax, __ebx, __ecx, __edx); |
|
61 + |
|
62 + if (__sig) |
|
63 + *__sig = __ebx; |
|
64 + |
|
65 + return __eax; |
|
66 +} |
|
67 + |
|
68 static bool |
|
69 has_cpuid_bit(unsigned int level, CPUIDRegister reg, unsigned int bit) |
|
70 { |
|
71 unsigned int regs[4]; |
|
72 - return __get_cpuid(level, ®s[0], ®s[1], ®s[2], ®s[3]) && |
|
73 - (regs[reg] & bit); |
|
74 + |
|
75 + unsigned int __ext = level & 0x80000000; |
|
76 + if (my_cpuid_max(__ext, 0) < level) |
|
77 + return false; |
|
78 + |
|
79 + _my_cpuid(level, regs[0], regs[1], regs[2], regs[3]); |
|
80 + return !!(unsigned(regs[reg]) & bit); |
|
81 } |
|
82 |
|
83 #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64)) |
|
84 |
|
85 // MSVC 2005 or newer on x86-32 or x86-64 |
|
86 #include <intrin.h> |
|
87 |
|
88 enum CPUIDRegister { eax = 0, ebx = 1, ecx = 2, edx = 3 }; |
|