slouken@739
|
1 |
/*
|
slouken@739
|
2 |
SDL - Simple DirectMedia Layer
|
slouken@769
|
3 |
Copyright (C) 1997-2004 Sam Lantinga
|
slouken@739
|
4 |
|
slouken@739
|
5 |
This library is free software; you can redistribute it and/or
|
slouken@739
|
6 |
modify it under the terms of the GNU Library General Public
|
slouken@739
|
7 |
License as published by the Free Software Foundation; either
|
slouken@739
|
8 |
version 2 of the License, or (at your option) any later version.
|
slouken@739
|
9 |
|
slouken@739
|
10 |
This library is distributed in the hope that it will be useful,
|
slouken@739
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
slouken@739
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
slouken@739
|
13 |
Library General Public License for more details.
|
slouken@739
|
14 |
|
slouken@739
|
15 |
You should have received a copy of the GNU Library General Public
|
slouken@739
|
16 |
License along with this library; if not, write to the Free
|
slouken@739
|
17 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
slouken@739
|
18 |
|
slouken@739
|
19 |
Sam Lantinga
|
slouken@739
|
20 |
slouken@libsdl.org
|
slouken@739
|
21 |
*/
|
slouken@739
|
22 |
|
slouken@739
|
23 |
#ifdef SAVE_RCSID
|
slouken@739
|
24 |
static char rcsid =
|
slouken@739
|
25 |
"@(#) $Id$";
|
slouken@739
|
26 |
#endif
|
slouken@739
|
27 |
|
slouken@739
|
28 |
/* CPU feature detection for SDL */
|
slouken@739
|
29 |
|
slouken@793
|
30 |
#ifdef unix /* FIXME: Better setjmp detection? */
|
slouken@793
|
31 |
#define USE_SETJMP
|
slouken@793
|
32 |
#include <signal.h>
|
slouken@793
|
33 |
#include <setjmp.h>
|
slouken@793
|
34 |
#endif
|
slouken@793
|
35 |
|
slouken@739
|
36 |
#include "SDL.h"
|
slouken@745
|
37 |
#include "SDL_cpuinfo.h"
|
slouken@745
|
38 |
|
slouken@778
|
39 |
#ifdef MACOSX
|
slouken@778
|
40 |
#include <sys/sysctl.h> /* For AltiVec check */
|
slouken@778
|
41 |
#endif
|
slouken@778
|
42 |
|
slouken@745
|
43 |
#define CPU_HAS_RDTSC 0x00000001
|
slouken@745
|
44 |
#define CPU_HAS_MMX 0x00000002
|
slouken@785
|
45 |
#define CPU_HAS_MMXEXT 0x00000004
|
slouken@785
|
46 |
#define CPU_HAS_3DNOW 0x00000010
|
slouken@785
|
47 |
#define CPU_HAS_3DNOWEXT 0x00000020
|
slouken@785
|
48 |
#define CPU_HAS_SSE 0x00000040
|
slouken@785
|
49 |
#define CPU_HAS_SSE2 0x00000080
|
slouken@785
|
50 |
#define CPU_HAS_ALTIVEC 0x00000100
|
slouken@745
|
51 |
|
slouken@1198
|
52 |
#if defined(USE_SETJMP) && defined(GCC_ALTIVEC)
|
slouken@793
|
53 |
/* This is the brute force way of detecting instruction sets...
|
slouken@793
|
54 |
the idea is borrowed from the libmpeg2 library - thanks!
|
slouken@793
|
55 |
*/
|
slouken@793
|
56 |
static jmp_buf jmpbuf;
|
slouken@793
|
57 |
static void illegal_instruction(int sig)
|
slouken@793
|
58 |
{
|
slouken@793
|
59 |
longjmp(jmpbuf, 1);
|
slouken@793
|
60 |
}
|
slouken@793
|
61 |
#endif // USE_SETJMP
|
slouken@793
|
62 |
|
slouken@745
|
63 |
static __inline__ int CPU_haveCPUID()
|
slouken@745
|
64 |
{
|
slouken@745
|
65 |
int has_CPUID = 0;
|
slouken@745
|
66 |
#if defined(__GNUC__) && defined(i386)
|
slouken@745
|
67 |
__asm__ (
|
slouken@745
|
68 |
" pushfl # Get original EFLAGS \n"
|
slouken@745
|
69 |
" popl %%eax \n"
|
slouken@745
|
70 |
" movl %%eax,%%ecx \n"
|
slouken@745
|
71 |
" xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n"
|
slouken@745
|
72 |
" pushl %%eax # Save new EFLAGS value on stack \n"
|
slouken@745
|
73 |
" popfl # Replace current EFLAGS value \n"
|
slouken@745
|
74 |
" pushfl # Get new EFLAGS \n"
|
slouken@745
|
75 |
" popl %%eax # Store new EFLAGS in EAX \n"
|
slouken@745
|
76 |
" xorl %%ecx,%%eax # Can not toggle ID bit, \n"
|
slouken@745
|
77 |
" jz 1f # Processor=80486 \n"
|
slouken@745
|
78 |
" movl $1,%0 # We have CPUID support \n"
|
slouken@745
|
79 |
"1: \n"
|
slouken@784
|
80 |
: "=m" (has_CPUID)
|
slouken@745
|
81 |
:
|
slouken@745
|
82 |
: "%eax", "%ecx"
|
slouken@745
|
83 |
);
|
slouken@881
|
84 |
#elif defined(__GNUC__) && defined(__x86_64__)
|
slouken@881
|
85 |
/* Technically, if this is being compiled under __x86_64__ then it has
|
slouken@881
|
86 |
CPUid by definition. But it's nice to be able to prove it. :) */
|
slouken@881
|
87 |
__asm__ (
|
slouken@881
|
88 |
" pushfq # Get original EFLAGS \n"
|
slouken@881
|
89 |
" popq %%rax \n"
|
slouken@881
|
90 |
" movq %%rax,%%rcx \n"
|
slouken@881
|
91 |
" xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n"
|
slouken@881
|
92 |
" pushq %%rax # Save new EFLAGS value on stack \n"
|
slouken@881
|
93 |
" popfq # Replace current EFLAGS value \n"
|
slouken@881
|
94 |
" pushfq # Get new EFLAGS \n"
|
slouken@881
|
95 |
" popq %%rax # Store new EFLAGS in EAX \n"
|
slouken@881
|
96 |
" xorl %%ecx,%%eax # Can not toggle ID bit, \n"
|
slouken@881
|
97 |
" jz 1f # Processor=80486 \n"
|
slouken@881
|
98 |
" movl $1,%0 # We have CPUID support \n"
|
slouken@881
|
99 |
"1: \n"
|
slouken@881
|
100 |
: "=m" (has_CPUID)
|
slouken@881
|
101 |
:
|
slouken@881
|
102 |
: "%rax", "%rcx"
|
slouken@881
|
103 |
);
|
icculus@1152
|
104 |
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_X86_))
|
slouken@749
|
105 |
__asm {
|
slouken@745
|
106 |
pushfd ; Get original EFLAGS
|
slouken@745
|
107 |
pop eax
|
slouken@745
|
108 |
mov ecx, eax
|
slouken@745
|
109 |
xor eax, 200000h ; Flip ID bit in EFLAGS
|
slouken@745
|
110 |
push eax ; Save new EFLAGS value on stack
|
slouken@745
|
111 |
popfd ; Replace current EFLAGS value
|
slouken@745
|
112 |
pushfd ; Get new EFLAGS
|
slouken@745
|
113 |
pop eax ; Store new EFLAGS in EAX
|
slouken@745
|
114 |
xor eax, ecx ; Can not toggle ID bit,
|
slouken@745
|
115 |
jz done ; Processor=80486
|
slouken@745
|
116 |
mov has_CPUID,1 ; We have CPUID support
|
slouken@745
|
117 |
done:
|
slouken@745
|
118 |
}
|
icculus@1229
|
119 |
#elif defined(__sun) && defined(__x86)
|
icculus@1229
|
120 |
__asm (
|
icculus@1229
|
121 |
" pushfl \n"
|
icculus@1229
|
122 |
" popl %eax \n"
|
icculus@1229
|
123 |
" movl %eax,%ecx \n"
|
icculus@1229
|
124 |
" xorl $0x200000,%eax \n"
|
icculus@1229
|
125 |
" pushl %eax \n"
|
icculus@1229
|
126 |
" popfl \n"
|
icculus@1229
|
127 |
" pushfl \n"
|
icculus@1229
|
128 |
" popl %eax \n"
|
icculus@1229
|
129 |
" xorl %ecx,%eax \n"
|
icculus@1229
|
130 |
" jz 1f \n"
|
icculus@1229
|
131 |
" movl $1,-8(%ebp) \n"
|
icculus@1229
|
132 |
"1: \n"
|
icculus@1229
|
133 |
);
|
icculus@1229
|
134 |
#elif defined(__sun) && defined(__amd64)
|
icculus@1229
|
135 |
__asm (
|
icculus@1229
|
136 |
" pushfq \n"
|
icculus@1229
|
137 |
" popq %rax \n"
|
icculus@1229
|
138 |
" movq %rax,%rcx \n"
|
icculus@1229
|
139 |
" xorl $0x200000,%eax \n"
|
icculus@1229
|
140 |
" pushq %rax \n"
|
icculus@1229
|
141 |
" popfq \n"
|
icculus@1229
|
142 |
" pushfq \n"
|
icculus@1229
|
143 |
" popq %rax \n"
|
icculus@1229
|
144 |
" xorl %ecx,%eax \n"
|
icculus@1229
|
145 |
" jz 1f \n"
|
icculus@1229
|
146 |
" movl $1,-8(%rbp) \n"
|
icculus@1229
|
147 |
"1: \n"
|
icculus@1229
|
148 |
);
|
slouken@745
|
149 |
#endif
|
slouken@745
|
150 |
return has_CPUID;
|
slouken@745
|
151 |
}
|
slouken@739
|
152 |
|
slouken@745
|
153 |
static __inline__ int CPU_getCPUIDFeatures()
|
slouken@745
|
154 |
{
|
slouken@745
|
155 |
int features = 0;
|
slouken@881
|
156 |
#if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) )
|
slouken@745
|
157 |
__asm__ (
|
slouken@785
|
158 |
" movl %%ebx,%%edi\n"
|
slouken@745
|
159 |
" xorl %%eax,%%eax # Set up for CPUID instruction \n"
|
slouken@745
|
160 |
" cpuid # Get and save vendor ID \n"
|
slouken@745
|
161 |
" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n"
|
slouken@745
|
162 |
" jl 1f # We dont have the CPUID instruction\n"
|
slouken@745
|
163 |
" xorl %%eax,%%eax \n"
|
slouken@745
|
164 |
" incl %%eax \n"
|
slouken@745
|
165 |
" cpuid # Get family/model/stepping/features\n"
|
slouken@745
|
166 |
" movl %%edx,%0 \n"
|
slouken@745
|
167 |
"1: \n"
|
slouken@785
|
168 |
" movl %%edi,%%ebx\n"
|
slouken@784
|
169 |
: "=m" (features)
|
slouken@745
|
170 |
:
|
slouken@887
|
171 |
: "%eax", "%ecx", "%edx", "%edi"
|
slouken@745
|
172 |
);
|
icculus@1152
|
173 |
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_X86_))
|
slouken@749
|
174 |
__asm {
|
slouken@745
|
175 |
xor eax, eax ; Set up for CPUID instruction
|
slouken@745
|
176 |
cpuid ; Get and save vendor ID
|
slouken@745
|
177 |
cmp eax, 1 ; Make sure 1 is valid input for CPUID
|
slouken@745
|
178 |
jl done ; We dont have the CPUID instruction
|
slouken@745
|
179 |
xor eax, eax
|
slouken@745
|
180 |
inc eax
|
slouken@745
|
181 |
cpuid ; Get family/model/stepping/features
|
slouken@745
|
182 |
mov features, edx
|
slouken@745
|
183 |
done:
|
slouken@745
|
184 |
}
|
icculus@1229
|
185 |
#elif defined(__sun) && (defined(__x86) || defined(__amd64))
|
icculus@1229
|
186 |
__asm(
|
icculus@1229
|
187 |
" movl %ebx,%edi\n"
|
icculus@1229
|
188 |
" xorl %eax,%eax \n"
|
icculus@1229
|
189 |
" cpuid \n"
|
icculus@1229
|
190 |
" cmpl $1,%eax \n"
|
icculus@1229
|
191 |
" jl 1f \n"
|
icculus@1229
|
192 |
" xorl %eax,%eax \n"
|
icculus@1229
|
193 |
" incl %eax \n"
|
icculus@1229
|
194 |
" cpuid \n"
|
icculus@1229
|
195 |
#ifdef __i386
|
icculus@1229
|
196 |
" movl %edx,-8(%ebp) \n"
|
icculus@1229
|
197 |
#else
|
icculus@1229
|
198 |
" movl %edx,-8(%rbp) \n"
|
icculus@1229
|
199 |
#endif
|
icculus@1229
|
200 |
"1: \n"
|
icculus@1229
|
201 |
" movl %edi,%ebx\n" );
|
slouken@745
|
202 |
#endif
|
slouken@745
|
203 |
return features;
|
slouken@745
|
204 |
}
|
slouken@745
|
205 |
|
slouken@785
|
206 |
static __inline__ int CPU_getCPUIDFeaturesExt()
|
slouken@785
|
207 |
{
|
slouken@785
|
208 |
int features = 0;
|
slouken@881
|
209 |
#if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) )
|
slouken@785
|
210 |
__asm__ (
|
slouken@785
|
211 |
" movl %%ebx,%%edi\n"
|
slouken@785
|
212 |
" movl $0x80000000,%%eax # Query for extended functions \n"
|
slouken@785
|
213 |
" cpuid # Get extended function limit \n"
|
slouken@785
|
214 |
" cmpl $0x80000001,%%eax \n"
|
slouken@787
|
215 |
" jl 1f # Nope, we dont have function 800000001h\n"
|
slouken@785
|
216 |
" movl $0x80000001,%%eax # Setup extended function 800000001h\n"
|
slouken@785
|
217 |
" cpuid # and get the information \n"
|
slouken@785
|
218 |
" movl %%edx,%0 \n"
|
slouken@785
|
219 |
"1: \n"
|
slouken@785
|
220 |
" movl %%edi,%%ebx\n"
|
slouken@785
|
221 |
: "=m" (features)
|
slouken@785
|
222 |
:
|
slouken@887
|
223 |
: "%eax", "%ecx", "%edx", "%edi"
|
slouken@785
|
224 |
);
|
icculus@1152
|
225 |
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_X86_))
|
slouken@785
|
226 |
__asm {
|
slouken@785
|
227 |
mov eax,80000000h ; Query for extended functions
|
slouken@785
|
228 |
cpuid ; Get extended function limit
|
slouken@785
|
229 |
cmp eax,80000001h
|
slouken@787
|
230 |
jl done ; Nope, we dont have function 800000001h
|
slouken@785
|
231 |
mov eax,80000001h ; Setup extended function 800000001h
|
slouken@785
|
232 |
cpuid ; and get the information
|
slouken@785
|
233 |
mov features,edx
|
slouken@785
|
234 |
done:
|
slouken@785
|
235 |
}
|
icculus@1229
|
236 |
#elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
|
icculus@1229
|
237 |
__asm (
|
icculus@1229
|
238 |
" movl %ebx,%edi\n"
|
icculus@1229
|
239 |
" movl $0x80000000,%eax \n"
|
icculus@1229
|
240 |
" cpuid \n"
|
icculus@1229
|
241 |
" cmpl $0x80000001,%eax \n"
|
icculus@1229
|
242 |
" jl 1f \n"
|
icculus@1229
|
243 |
" movl $0x80000001,%eax \n"
|
icculus@1229
|
244 |
" cpuid \n"
|
icculus@1229
|
245 |
#ifdef __i386
|
icculus@1229
|
246 |
" movl %edx,-8(%ebp) \n"
|
icculus@1229
|
247 |
#else
|
icculus@1229
|
248 |
" movl %edx,-8(%rbp) \n"
|
icculus@1229
|
249 |
#endif
|
icculus@1229
|
250 |
"1: \n"
|
icculus@1229
|
251 |
" movl %edi,%ebx\n"
|
icculus@1229
|
252 |
);
|
slouken@785
|
253 |
#endif
|
slouken@785
|
254 |
return features;
|
slouken@785
|
255 |
}
|
slouken@785
|
256 |
|
slouken@745
|
257 |
static __inline__ int CPU_haveRDTSC()
|
slouken@745
|
258 |
{
|
slouken@745
|
259 |
if ( CPU_haveCPUID() ) {
|
slouken@745
|
260 |
return (CPU_getCPUIDFeatures() & 0x00000010);
|
slouken@745
|
261 |
}
|
slouken@745
|
262 |
return 0;
|
slouken@745
|
263 |
}
|
slouken@739
|
264 |
|
slouken@745
|
265 |
static __inline__ int CPU_haveMMX()
|
slouken@745
|
266 |
{
|
slouken@745
|
267 |
if ( CPU_haveCPUID() ) {
|
slouken@745
|
268 |
return (CPU_getCPUIDFeatures() & 0x00800000);
|
slouken@745
|
269 |
}
|
slouken@745
|
270 |
return 0;
|
slouken@745
|
271 |
}
|
slouken@745
|
272 |
|
slouken@785
|
273 |
static __inline__ int CPU_haveMMXExt()
|
slouken@785
|
274 |
{
|
slouken@785
|
275 |
if ( CPU_haveCPUID() ) {
|
slouken@785
|
276 |
return (CPU_getCPUIDFeaturesExt() & 0x00400000);
|
slouken@785
|
277 |
}
|
slouken@785
|
278 |
return 0;
|
slouken@785
|
279 |
}
|
slouken@785
|
280 |
|
slouken@745
|
281 |
static __inline__ int CPU_have3DNow()
|
slouken@745
|
282 |
{
|
slouken@785
|
283 |
if ( CPU_haveCPUID() ) {
|
slouken@785
|
284 |
return (CPU_getCPUIDFeaturesExt() & 0x80000000);
|
slouken@747
|
285 |
}
|
slouken@785
|
286 |
return 0;
|
slouken@785
|
287 |
}
|
slouken@785
|
288 |
|
slouken@785
|
289 |
static __inline__ int CPU_have3DNowExt()
|
slouken@785
|
290 |
{
|
slouken@785
|
291 |
if ( CPU_haveCPUID() ) {
|
slouken@785
|
292 |
return (CPU_getCPUIDFeaturesExt() & 0x40000000);
|
slouken@745
|
293 |
}
|
slouken@785
|
294 |
return 0;
|
slouken@745
|
295 |
}
|
slouken@745
|
296 |
|
slouken@745
|
297 |
static __inline__ int CPU_haveSSE()
|
slouken@745
|
298 |
{
|
slouken@745
|
299 |
if ( CPU_haveCPUID() ) {
|
slouken@745
|
300 |
return (CPU_getCPUIDFeatures() & 0x02000000);
|
slouken@745
|
301 |
}
|
slouken@745
|
302 |
return 0;
|
slouken@745
|
303 |
}
|
slouken@739
|
304 |
|
slouken@785
|
305 |
static __inline__ int CPU_haveSSE2()
|
slouken@785
|
306 |
{
|
slouken@785
|
307 |
if ( CPU_haveCPUID() ) {
|
slouken@785
|
308 |
return (CPU_getCPUIDFeatures() & 0x04000000);
|
slouken@785
|
309 |
}
|
slouken@785
|
310 |
return 0;
|
slouken@785
|
311 |
}
|
slouken@785
|
312 |
|
slouken@778
|
313 |
static __inline__ int CPU_haveAltiVec()
|
slouken@778
|
314 |
{
|
slouken@796
|
315 |
volatile int altivec = 0;
|
slouken@778
|
316 |
#ifdef MACOSX
|
slouken@778
|
317 |
int selectors[2] = { CTL_HW, HW_VECTORUNIT };
|
slouken@778
|
318 |
int hasVectorUnit = 0;
|
slouken@778
|
319 |
size_t length = sizeof(hasVectorUnit);
|
slouken@778
|
320 |
int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
|
slouken@778
|
321 |
if( 0 == error )
|
slouken@793
|
322 |
altivec = (hasVectorUnit != 0);
|
slouken@795
|
323 |
#elif defined(USE_SETJMP) && defined(GCC_ALTIVEC)
|
slouken@793
|
324 |
void (*handler)(int sig);
|
slouken@793
|
325 |
handler = signal(SIGILL, illegal_instruction);
|
slouken@793
|
326 |
if ( setjmp(jmpbuf) == 0 ) {
|
slouken@793
|
327 |
asm volatile ("mtspr 256, %0\n\t"
|
slouken@793
|
328 |
"vand %%v0, %%v0, %%v0"
|
slouken@793
|
329 |
:
|
slouken@793
|
330 |
: "r" (-1));
|
slouken@793
|
331 |
altivec = 1;
|
slouken@793
|
332 |
}
|
slouken@793
|
333 |
signal(SIGILL, handler);
|
slouken@778
|
334 |
#endif
|
slouken@793
|
335 |
return altivec;
|
slouken@778
|
336 |
}
|
slouken@778
|
337 |
|
slouken@739
|
338 |
static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
|
slouken@739
|
339 |
|
slouken@739
|
340 |
static Uint32 SDL_GetCPUFeatures()
|
slouken@739
|
341 |
{
|
slouken@739
|
342 |
if ( SDL_CPUFeatures == 0xFFFFFFFF ) {
|
slouken@739
|
343 |
SDL_CPUFeatures = 0;
|
slouken@745
|
344 |
if ( CPU_haveRDTSC() ) {
|
slouken@745
|
345 |
SDL_CPUFeatures |= CPU_HAS_RDTSC;
|
slouken@745
|
346 |
}
|
slouken@739
|
347 |
if ( CPU_haveMMX() ) {
|
slouken@739
|
348 |
SDL_CPUFeatures |= CPU_HAS_MMX;
|
slouken@739
|
349 |
}
|
slouken@786
|
350 |
if ( CPU_haveMMXExt() ) {
|
slouken@786
|
351 |
SDL_CPUFeatures |= CPU_HAS_MMXEXT;
|
slouken@786
|
352 |
}
|
slouken@739
|
353 |
if ( CPU_have3DNow() ) {
|
slouken@739
|
354 |
SDL_CPUFeatures |= CPU_HAS_3DNOW;
|
slouken@739
|
355 |
}
|
slouken@786
|
356 |
if ( CPU_have3DNowExt() ) {
|
slouken@786
|
357 |
SDL_CPUFeatures |= CPU_HAS_3DNOWEXT;
|
slouken@786
|
358 |
}
|
slouken@739
|
359 |
if ( CPU_haveSSE() ) {
|
slouken@739
|
360 |
SDL_CPUFeatures |= CPU_HAS_SSE;
|
slouken@739
|
361 |
}
|
slouken@786
|
362 |
if ( CPU_haveSSE2() ) {
|
slouken@786
|
363 |
SDL_CPUFeatures |= CPU_HAS_SSE2;
|
slouken@786
|
364 |
}
|
slouken@778
|
365 |
if ( CPU_haveAltiVec() ) {
|
slouken@778
|
366 |
SDL_CPUFeatures |= CPU_HAS_ALTIVEC;
|
slouken@778
|
367 |
}
|
slouken@739
|
368 |
}
|
slouken@739
|
369 |
return SDL_CPUFeatures;
|
slouken@739
|
370 |
}
|
slouken@739
|
371 |
|
slouken@745
|
372 |
SDL_bool SDL_HasRDTSC()
|
slouken@745
|
373 |
{
|
slouken@745
|
374 |
if ( SDL_GetCPUFeatures() & CPU_HAS_RDTSC ) {
|
slouken@745
|
375 |
return SDL_TRUE;
|
slouken@745
|
376 |
}
|
slouken@745
|
377 |
return SDL_FALSE;
|
slouken@745
|
378 |
}
|
slouken@745
|
379 |
|
slouken@739
|
380 |
SDL_bool SDL_HasMMX()
|
slouken@739
|
381 |
{
|
slouken@739
|
382 |
if ( SDL_GetCPUFeatures() & CPU_HAS_MMX ) {
|
slouken@739
|
383 |
return SDL_TRUE;
|
slouken@739
|
384 |
}
|
slouken@739
|
385 |
return SDL_FALSE;
|
slouken@739
|
386 |
}
|
slouken@739
|
387 |
|
slouken@804
|
388 |
SDL_bool SDL_HasMMXExt()
|
slouken@804
|
389 |
{
|
slouken@804
|
390 |
if ( SDL_GetCPUFeatures() & CPU_HAS_MMXEXT ) {
|
slouken@804
|
391 |
return SDL_TRUE;
|
slouken@804
|
392 |
}
|
slouken@804
|
393 |
return SDL_FALSE;
|
slouken@804
|
394 |
}
|
slouken@804
|
395 |
|
slouken@739
|
396 |
SDL_bool SDL_Has3DNow()
|
slouken@739
|
397 |
{
|
slouken@739
|
398 |
if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOW ) {
|
slouken@739
|
399 |
return SDL_TRUE;
|
slouken@739
|
400 |
}
|
slouken@739
|
401 |
return SDL_FALSE;
|
slouken@739
|
402 |
}
|
slouken@739
|
403 |
|
slouken@804
|
404 |
SDL_bool SDL_Has3DNowExt()
|
slouken@804
|
405 |
{
|
slouken@804
|
406 |
if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT ) {
|
slouken@804
|
407 |
return SDL_TRUE;
|
slouken@804
|
408 |
}
|
slouken@804
|
409 |
return SDL_FALSE;
|
slouken@804
|
410 |
}
|
slouken@804
|
411 |
|
slouken@739
|
412 |
SDL_bool SDL_HasSSE()
|
slouken@739
|
413 |
{
|
slouken@739
|
414 |
if ( SDL_GetCPUFeatures() & CPU_HAS_SSE ) {
|
slouken@739
|
415 |
return SDL_TRUE;
|
slouken@739
|
416 |
}
|
slouken@739
|
417 |
return SDL_FALSE;
|
slouken@739
|
418 |
}
|
slouken@739
|
419 |
|
slouken@804
|
420 |
SDL_bool SDL_HasSSE2()
|
slouken@804
|
421 |
{
|
slouken@804
|
422 |
if ( SDL_GetCPUFeatures() & CPU_HAS_SSE2 ) {
|
slouken@804
|
423 |
return SDL_TRUE;
|
slouken@804
|
424 |
}
|
slouken@804
|
425 |
return SDL_FALSE;
|
slouken@804
|
426 |
}
|
slouken@804
|
427 |
|
slouken@778
|
428 |
SDL_bool SDL_HasAltiVec()
|
slouken@778
|
429 |
{
|
slouken@778
|
430 |
if ( SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC ) {
|
slouken@778
|
431 |
return SDL_TRUE;
|
slouken@778
|
432 |
}
|
slouken@778
|
433 |
return SDL_FALSE;
|
slouken@778
|
434 |
}
|
slouken@778
|
435 |
|
slouken@739
|
436 |
#ifdef TEST_MAIN
|
slouken@739
|
437 |
|
slouken@739
|
438 |
#include <stdio.h>
|
slouken@739
|
439 |
|
slouken@739
|
440 |
int main()
|
slouken@739
|
441 |
{
|
slouken@778
|
442 |
printf("RDTSC: %d\n", SDL_HasRDTSC());
|
slouken@739
|
443 |
printf("MMX: %d\n", SDL_HasMMX());
|
slouken@785
|
444 |
printf("MMXExt: %d\n", SDL_HasMMXExt());
|
slouken@739
|
445 |
printf("3DNow: %d\n", SDL_Has3DNow());
|
slouken@785
|
446 |
printf("3DNowExt: %d\n", SDL_Has3DNowExt());
|
slouken@739
|
447 |
printf("SSE: %d\n", SDL_HasSSE());
|
slouken@785
|
448 |
printf("SSE2: %d\n", SDL_HasSSE2());
|
slouken@778
|
449 |
printf("AltiVec: %d\n", SDL_HasAltiVec());
|
slouken@745
|
450 |
return 0;
|
slouken@739
|
451 |
}
|
slouken@739
|
452 |
|
slouken@739
|
453 |
#endif /* TEST_MAIN */
|