Mercurial > sdl-ios-xcode
annotate src/cpuinfo/SDL_cpuinfo.c @ 786:e1e0a0a94570
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 24 Jan 2004 05:57:56 +0000 |
parents | ca06a994f03c |
children | 07760c8854d1 |
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 |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
749
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
739
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 |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
33 #ifdef MACOSX |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
34 #include <sys/sysctl.h> /* For AltiVec check */ |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
35 #endif |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
36 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
37 #define CPU_HAS_RDTSC 0x00000001 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
38 #define CPU_HAS_MMX 0x00000002 |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
39 #define CPU_HAS_MMXEXT 0x00000004 |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
40 #define CPU_HAS_3DNOW 0x00000010 |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
41 #define CPU_HAS_3DNOWEXT 0x00000020 |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
42 #define CPU_HAS_SSE 0x00000040 |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
43 #define CPU_HAS_SSE2 0x00000080 |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
44 #define CPU_HAS_ALTIVEC 0x00000100 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
45 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
46 static __inline__ int CPU_haveCPUID() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
47 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
48 int has_CPUID = 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
49 #if defined(__GNUC__) && defined(i386) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
50 __asm__ ( |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
51 " pushfl # Get original EFLAGS \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
52 " popl %%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
53 " movl %%eax,%%ecx \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
54 " 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
|
55 " 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
|
56 " popfl # Replace current EFLAGS value \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
57 " pushfl # Get new EFLAGS \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
58 " 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
|
59 " 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
|
60 " jz 1f # Processor=80486 \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
61 " 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
|
62 "1: \n" |
784
a2dde6aff60e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
778
diff
changeset
|
63 : "=m" (has_CPUID) |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
64 : |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
65 : "%eax", "%ecx" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
66 ); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
67 #elif defined(_MSC_VER) |
749
06cdd106d61c
Updated Visual C++ support
Sam Lantinga <slouken@libsdl.org>
parents:
747
diff
changeset
|
68 __asm { |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
69 pushfd ; Get original EFLAGS |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
70 pop eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
71 mov ecx, eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
72 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
|
73 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
|
74 popfd ; Replace current EFLAGS value |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
75 pushfd ; Get new EFLAGS |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
76 pop eax ; Store new EFLAGS in EAX |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
77 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
|
78 jz done ; Processor=80486 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
79 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
|
80 done: |
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 #endif |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
83 return has_CPUID; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
84 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
86 static __inline__ int CPU_getCPUIDFeatures() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
87 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
88 int features = 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
89 #if defined(__GNUC__) && defined(i386) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
90 __asm__ ( |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
91 " movl %%ebx,%%edi\n" |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
92 " 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
|
93 " cpuid # Get and save vendor ID \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
94 " 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
|
95 " 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
|
96 " xorl %%eax,%%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
97 " incl %%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
98 " cpuid # Get family/model/stepping/features\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
99 " movl %%edx,%0 \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
100 "1: \n" |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
101 " movl %%edi,%%ebx\n" |
784
a2dde6aff60e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
778
diff
changeset
|
102 : "=m" (features) |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
103 : |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
104 : "%eax", "%ebx", "%ecx", "%edx", "%edi" |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
105 ); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
106 #elif defined(_MSC_VER) |
749
06cdd106d61c
Updated Visual C++ support
Sam Lantinga <slouken@libsdl.org>
parents:
747
diff
changeset
|
107 __asm { |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
108 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
|
109 cpuid ; Get and save vendor ID |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
110 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
|
111 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
|
112 xor eax, eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
113 inc eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
114 cpuid ; Get family/model/stepping/features |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
115 mov features, edx |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
116 done: |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
117 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
118 #endif |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
119 return features; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
120 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
121 |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
122 static __inline__ int CPU_getCPUIDFeaturesExt() |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
123 { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
124 int features = 0; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
125 #if defined(__GNUC__) && defined(i386) |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
126 __asm__ ( |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
127 " movl %%ebx,%%edi\n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
128 " movl $0x80000000,%%eax # Query for extended functions \n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
129 " cpuid # Get extended function limit \n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
130 " cmpl $0x80000001,%%eax \n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
131 " jbe 1f # Nope, we dont have function 800000001h\n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
132 " movl $0x80000001,%%eax # Setup extended function 800000001h\n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
133 " cpuid # and get the information \n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
134 " movl %%edx,%0 \n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
135 "1: \n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
136 " movl %%edi,%%ebx\n" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
137 : "=m" (features) |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
138 : |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
139 : "%eax", "%ebx", "%ecx", "%edx", "%edi" |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
140 ); |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
141 #elif defined(_MSC_VER) |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
142 __asm { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
143 mov eax,80000000h ; Query for extended functions |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
144 cpuid ; Get extended function limit |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
145 cmp eax,80000001h |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
146 jbe done ; Nope, we dont have function 800000001h |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
147 mov eax,80000001h ; Setup extended function 800000001h |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
148 cpuid ; and get the information |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
149 mov features,edx |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
150 done: |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
151 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
152 #endif |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
153 return features; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
154 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
155 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
156 static __inline__ int CPU_haveRDTSC() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
157 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
158 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
159 return (CPU_getCPUIDFeatures() & 0x00000010); |
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 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
162 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
164 static __inline__ int CPU_haveMMX() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
165 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
166 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
167 return (CPU_getCPUIDFeatures() & 0x00800000); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
168 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
169 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
170 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
171 |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
172 static __inline__ int CPU_haveMMXExt() |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
173 { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
174 if ( CPU_haveCPUID() ) { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
175 return (CPU_getCPUIDFeaturesExt() & 0x00400000); |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
176 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
177 return 0; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
178 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
179 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
180 static __inline__ int CPU_have3DNow() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
181 { |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
182 if ( CPU_haveCPUID() ) { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
183 return (CPU_getCPUIDFeaturesExt() & 0x80000000); |
747
da36f59485da
Check for CPUID before checking for 3DNow!
Sam Lantinga <slouken@libsdl.org>
parents:
745
diff
changeset
|
184 } |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
185 return 0; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
186 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
187 |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
188 static __inline__ int CPU_have3DNowExt() |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
189 { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
190 if ( CPU_haveCPUID() ) { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
191 return (CPU_getCPUIDFeaturesExt() & 0x40000000); |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
192 } |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
193 return 0; |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
194 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
195 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
196 static __inline__ int CPU_haveSSE() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
197 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
198 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
199 return (CPU_getCPUIDFeatures() & 0x02000000); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
200 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
201 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
202 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
204 static __inline__ int CPU_haveSSE2() |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
205 { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
206 if ( CPU_haveCPUID() ) { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
207 return (CPU_getCPUIDFeatures() & 0x04000000); |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
208 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
209 return 0; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
210 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
211 |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
212 static __inline__ int CPU_haveAltiVec() |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
213 { |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
214 #ifdef MACOSX |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
215 /* TODO: This check works on OS X. It would be nice to detect AltiVec |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
216 properly on for example Linux/PPC, too. But I don't know how that |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
217 is done in Linux (or FreeBSD, or whatever other OS you run PPC :-) |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
218 */ |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
219 int selectors[2] = { CTL_HW, HW_VECTORUNIT }; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
220 int hasVectorUnit = 0; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
221 size_t length = sizeof(hasVectorUnit); |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
222 int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0); |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
223 if( 0 == error ) |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
224 return hasVectorUnit != 0; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
225 #endif |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
226 return 0; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
227 } |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
228 |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 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
|
230 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 static Uint32 SDL_GetCPUFeatures() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 if ( SDL_CPUFeatures == 0xFFFFFFFF ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 SDL_CPUFeatures = 0; |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
235 if ( CPU_haveRDTSC() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
236 SDL_CPUFeatures |= CPU_HAS_RDTSC; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
237 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 if ( CPU_haveMMX() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 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
|
240 } |
786
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
241 if ( CPU_haveMMXExt() ) { |
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
242 SDL_CPUFeatures |= CPU_HAS_MMXEXT; |
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
243 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 if ( CPU_have3DNow() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 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
|
246 } |
786
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
247 if ( CPU_have3DNowExt() ) { |
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
248 SDL_CPUFeatures |= CPU_HAS_3DNOWEXT; |
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
249 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 if ( CPU_haveSSE() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 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
|
252 } |
786
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
253 if ( CPU_haveSSE2() ) { |
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
254 SDL_CPUFeatures |= CPU_HAS_SSE2; |
e1e0a0a94570
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
785
diff
changeset
|
255 } |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
256 if ( CPU_haveAltiVec() ) { |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
257 SDL_CPUFeatures |= CPU_HAS_ALTIVEC; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
258 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 return SDL_CPUFeatures; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
263 SDL_bool SDL_HasRDTSC() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
264 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
265 if ( SDL_GetCPUFeatures() & CPU_HAS_RDTSC ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
266 return SDL_TRUE; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
267 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
268 return SDL_FALSE; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
269 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
270 |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 SDL_bool SDL_HasMMX() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 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
|
274 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 return SDL_FALSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 SDL_bool SDL_Has3DNow() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 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
|
282 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 return SDL_FALSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 SDL_bool SDL_HasSSE() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 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
|
290 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 return SDL_FALSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
295 SDL_bool SDL_HasAltiVec() |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
296 { |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
297 if ( SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC ) { |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
298 return SDL_TRUE; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
299 } |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
300 return SDL_FALSE; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
301 } |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
302 |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
303 SDL_bool SDL_HasMMXExt() |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
304 { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
305 if ( SDL_GetCPUFeatures() & CPU_HAS_MMXEXT ) { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
306 return SDL_TRUE; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
307 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
308 return SDL_FALSE; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
309 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
310 |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
311 SDL_bool SDL_Has3DNowExt() |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
312 { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
313 if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT ) { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
314 return SDL_TRUE; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
315 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
316 return SDL_FALSE; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
317 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
318 |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
319 SDL_bool SDL_HasSSE2() |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
320 { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
321 if ( SDL_GetCPUFeatures() & CPU_HAS_SSE2 ) { |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
322 return SDL_TRUE; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
323 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
324 return SDL_FALSE; |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
325 } |
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
326 |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 #ifdef TEST_MAIN |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 #include <stdio.h> |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 int main() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 { |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
333 printf("RDTSC: %d\n", SDL_HasRDTSC()); |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 printf("MMX: %d\n", SDL_HasMMX()); |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
335 printf("MMXExt: %d\n", SDL_HasMMXExt()); |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 printf("3DNow: %d\n", SDL_Has3DNow()); |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
337 printf("3DNowExt: %d\n", SDL_Has3DNowExt()); |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 printf("SSE: %d\n", SDL_HasSSE()); |
785
ca06a994f03c
Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents:
784
diff
changeset
|
339 printf("SSE2: %d\n", SDL_HasSSE2()); |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
340 printf("AltiVec: %d\n", SDL_HasAltiVec()); |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
341 return 0; |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 #endif /* TEST_MAIN */ |