Mercurial > sdl-ios-xcode
comparison src/cpuinfo/SDL_cpuinfo.c @ 3584:41d01d70659c
Fixed cpuid assembly to work on PIC code
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 16 Dec 2009 16:42:04 +0000 |
parents | 951dd6a5d1a2 |
children | b6758aee0dd4 |
comparison
equal
deleted
inserted
replaced
3583:65f66674b7fb | 3584:41d01d70659c |
---|---|
120 done: | 120 done: |
121 } | 121 } |
122 #elif defined(__sun) && defined(__i386) | 122 #elif defined(__sun) && defined(__i386) |
123 __asm ( | 123 __asm ( |
124 " pushfl \n" | 124 " pushfl \n" |
125 " popl %eax \n" | 125 " popl %eax \n" |
126 " movl %eax,%ecx \n" | 126 " movl %eax,%ecx \n" |
127 " xorl $0x200000,%eax \n" | 127 " xorl $0x200000,%eax \n" |
128 " pushl %eax \n" | 128 " pushl %eax \n" |
129 " popfl \n" | 129 " popfl \n" |
130 " pushfl \n" | 130 " pushfl \n" |
131 " popl %eax \n" | 131 " popl %eax \n" |
132 " xorl %ecx,%eax \n" | 132 " xorl %ecx,%eax \n" |
133 " jz 1f \n" | 133 " jz 1f \n" |
134 " movl $1,-8(%ebp) \n" | 134 " movl $1,-8(%ebp) \n" |
135 "1: \n" | 135 "1: \n" |
136 ); | 136 ); |
137 #elif defined(__sun) && defined(__amd64) | 137 #elif defined(__sun) && defined(__amd64) |
138 __asm ( | 138 __asm ( |
139 " pushfq \n" | 139 " pushfq \n" |
154 return has_CPUID; | 154 return has_CPUID; |
155 } | 155 } |
156 | 156 |
157 #if defined(__GNUC__) && (defined(i386) || defined(__x86_64__)) | 157 #if defined(__GNUC__) && (defined(i386) || defined(__x86_64__)) |
158 #define cpuid(func, a, b, c, d) \ | 158 #define cpuid(func, a, b, c, d) \ |
159 __asm__ __volatile__ ("cpuid": \ | 159 __asm__ __volatile__ ( \ |
160 "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (func)) | 160 " pushl %%ebx \n" \ |
161 " cpuid \n" \ | |
162 " movl %%ebx, %%esi \n" \ | |
163 " popl %%ebx \n" : \ | |
164 "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func)) | |
161 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) | 165 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) |
162 #define cpuid(func, a, b, c, d) \ | 166 #define cpuid(func, a, b, c, d) \ |
163 __asm { \ | 167 __asm { \ |
164 __asm mov eax, func \ | 168 __asm mov eax, func \ |
165 __asm cpuid \ | 169 __asm cpuid \ |