Mercurial > sdl-ios-xcode
annotate src/cpuinfo/SDL_cpuinfo.c @ 745:71ee03909f42
Greatly simplified the SDL CPU info code
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 24 Nov 2003 09:16:52 +0000 |
parents | 22dbf364c017 |
children | da36f59485da |
rev | line source |
---|---|
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Library General Public License for more details. |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #ifdef SAVE_RCSID |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 static char rcsid = |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 "@(#) $Id$"; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #endif |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 /* CPU feature detection for SDL */ |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include "SDL.h" |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
31 #include "SDL_cpuinfo.h" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
32 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
33 #define CPU_HAS_RDTSC 0x00000001 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
34 #define CPU_HAS_MMX 0x00000002 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
35 #define CPU_HAS_3DNOW 0x00000004 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
36 #define CPU_HAS_SSE 0x00000008 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
37 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
38 static __inline__ int CPU_haveCPUID() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
39 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
40 int has_CPUID = 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
41 #if defined(__GNUC__) && defined(i386) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
42 __asm__ ( |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
43 "push %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
44 " pushfl # Get original EFLAGS \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
45 " popl %%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
46 " movl %%eax,%%ecx \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
47 " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
48 " pushl %%eax # Save new EFLAGS value on stack \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
49 " popfl # Replace current EFLAGS value \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
50 " pushfl # Get new EFLAGS \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
51 " popl %%eax # Store new EFLAGS in EAX \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
52 " xorl %%ecx,%%eax # Can not toggle ID bit, \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
53 " jz 1f # Processor=80486 \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
54 " movl $1,%0 # We have CPUID support \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
55 "1: \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
56 "pop %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
57 : "=r" (has_CPUID) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
58 : |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
59 : "%eax", "%ecx" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
60 ); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
61 #elif defined(_MSC_VER) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
62 __asm__ { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
63 pushfd ; Get original EFLAGS |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
64 pop eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
65 mov ecx, eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
66 xor eax, 200000h ; Flip ID bit in EFLAGS |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
67 push eax ; Save new EFLAGS value on stack |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
68 popfd ; Replace current EFLAGS value |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
69 pushfd ; Get new EFLAGS |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
70 pop eax ; Store new EFLAGS in EAX |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
71 xor eax, ecx ; Can not toggle ID bit, |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
72 jz done ; Processor=80486 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
73 mov has_CPUID,1 ; We have CPUID support |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
74 done: |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
75 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
76 #endif |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
77 return has_CPUID; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
78 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
80 static __inline__ int CPU_getCPUIDFeatures() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
81 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
82 int features = 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
83 #if defined(__GNUC__) && defined(i386) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
84 __asm__ ( |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
85 "push %%ebx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
86 "push %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
87 "push %%edx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
88 " xorl %%eax,%%eax # Set up for CPUID instruction \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
89 " cpuid # Get and save vendor ID \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
90 " cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
91 " jl 1f # We dont have the CPUID instruction\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
92 " xorl %%eax,%%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
93 " incl %%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
94 " cpuid # Get family/model/stepping/features\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
95 " movl %%edx,%0 \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
96 "1: \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
97 "pop %%edx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
98 "pop %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
99 "pop %%ebx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
100 : "=r" (features) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
101 : |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
102 : "%eax", "%ebx", "%ecx", "%edx" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
103 ); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
104 #elif defined(_MSC_VER) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
105 __asm__ { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
106 xor eax, eax ; Set up for CPUID instruction |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
107 cpuid ; Get and save vendor ID |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
108 cmp eax, 1 ; Make sure 1 is valid input for CPUID |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
109 jl done ; We dont have the CPUID instruction |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
110 xor eax, eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
111 inc eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
112 cpuid ; Get family/model/stepping/features |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
113 mov features, edx |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
114 done: |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
115 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
116 #endif |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
117 return features; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
118 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
119 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
120 static __inline__ int CPU_haveRDTSC() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
121 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
122 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
123 return (CPU_getCPUIDFeatures() & 0x00000010); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
124 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
125 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
126 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
128 static __inline__ int CPU_haveMMX() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
129 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
130 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
131 return (CPU_getCPUIDFeatures() & 0x00800000); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
132 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
133 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
134 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
135 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
136 static __inline__ int CPU_have3DNow() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
137 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
138 int has_3DNow = 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
139 #if defined(__GNUC__) && defined(i386) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
140 __asm__ ( |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
141 "push %%ebx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
142 "push %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
143 "push %%edx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
144 " movl $0x80000000,%%eax # Query for extended functions \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
145 " cpuid # Get extended function limit \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
146 " cmpl $0x80000001,%%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
147 " jbe 1f # Nope, we dont have function 800000001h\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
148 " movl $0x80000001,%%eax # Setup extended function 800000001h\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
149 " cpuid # and get the information \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
150 " testl $0x80000000,%%edx # Bit 31 is set if 3DNow! present \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
151 " jz 1f # Nope, we dont have 3DNow support\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
152 " movl $1,%0 # Yep, we have 3DNow! support! \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
153 "1: \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
154 "pop %%edx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
155 "pop %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
156 "pop %%ebx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
157 : "=r" (has_3DNow) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
158 : |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
159 : "%eax", "%ebx", "%ecx", "%edx" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
160 ); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
161 #elif defined(_MSC_VER) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
162 __asm__ { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
163 mov eax,80000000h ; Query for extended functions |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
164 cpuid ; Get extended function limit |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
165 cmp eax,80000001h |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
166 jbe done ; Nope, we dont have function 800000001h |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
167 mov eax,80000001h ; Setup extended function 800000001h |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
168 cpuid ; and get the information |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
169 test edx,80000000h ; Bit 31 is set if 3DNow! present |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
170 jz done ; Nope, we dont have 3DNow support |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
171 mov has_3DNow,1 ; Yep, we have 3DNow! support! |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
172 done: |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
173 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
174 #endif |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
175 return has_3DNow; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
176 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
177 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
178 static __inline__ int CPU_haveSSE() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
179 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
180 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
181 return (CPU_getCPUIDFeatures() & 0x02000000); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
182 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
183 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
184 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 static Uint32 SDL_CPUFeatures = 0xFFFFFFFF; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 static Uint32 SDL_GetCPUFeatures() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 if ( SDL_CPUFeatures == 0xFFFFFFFF ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 SDL_CPUFeatures = 0; |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
192 if ( CPU_haveRDTSC() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
193 SDL_CPUFeatures |= CPU_HAS_RDTSC; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
194 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 if ( CPU_haveMMX() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 SDL_CPUFeatures |= CPU_HAS_MMX; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 if ( CPU_have3DNow() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 SDL_CPUFeatures |= CPU_HAS_3DNOW; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 if ( CPU_haveSSE() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 SDL_CPUFeatures |= CPU_HAS_SSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 return SDL_CPUFeatures; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
208 SDL_bool SDL_HasRDTSC() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
209 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
210 if ( SDL_GetCPUFeatures() & CPU_HAS_RDTSC ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
211 return SDL_TRUE; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
212 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
213 return SDL_FALSE; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
214 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
215 |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 SDL_bool SDL_HasMMX() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 if ( SDL_GetCPUFeatures() & CPU_HAS_MMX ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 return SDL_FALSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 SDL_bool SDL_Has3DNow() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOW ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 return SDL_FALSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 SDL_bool SDL_HasSSE() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 if ( SDL_GetCPUFeatures() & CPU_HAS_SSE ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 return SDL_FALSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 #ifdef TEST_MAIN |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 #include <stdio.h> |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 int main() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 printf("MMX: %d\n", SDL_HasMMX()); |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 printf("3DNow: %d\n", SDL_Has3DNow()); |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 printf("SSE: %d\n", SDL_HasSSE()); |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
249 return 0; |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 #endif /* TEST_MAIN */ |