Mercurial > sdl-ios-xcode
annotate src/cpuinfo/SDL_cpuinfo.c @ 779:68c8da837fc0
Date: Tue, 6 Jan 2004 21:54:02 +0100
From: Max Horn
Subject: Auto hide mouse & other changes
the attached bug adds the auto-hide-mouse feature I talked about
earlier. Turned out it was a lot simpler than I thought, simply by
using our existing code :-). I actually spent much more time on fixing
various bugs in the code and correcting (IMO) some behavior (although,
due to the lack of real specs for SDL, it's probably arguable what
'correct' means...).
* adds auto (un)hiding of mouse depending on whether it is in- or
outside the game window
* computation of course coordinates is correct now (it often and
reproducible got out of sync with the old code, since the NSEvent
window was in some cases *not* our window anymore, so locationInWindow
returned wrong results)
* added a method which at any time returns the mouse coords, relative
to our window
* fixed handling of lost/gain input/mouse/app focus "events"
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 07 Jan 2004 15:01:51 +0000 |
parents | 8ac3f46f9d09 |
children | a2dde6aff60e |
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 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
39 #define CPU_HAS_3DNOW 0x00000004 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
40 #define CPU_HAS_SSE 0x00000008 |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
41 #define CPU_HAS_ALTIVEC 0x00000010 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
42 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
43 static __inline__ int CPU_haveCPUID() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
44 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
45 int has_CPUID = 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
46 #if defined(__GNUC__) && defined(i386) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
47 __asm__ ( |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
48 "push %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
49 " pushfl # Get original EFLAGS \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
50 " popl %%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
51 " movl %%eax,%%ecx \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
52 " 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
|
53 " 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
|
54 " popfl # Replace current EFLAGS value \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
55 " pushfl # Get new EFLAGS \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
56 " 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
|
57 " 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
|
58 " jz 1f # Processor=80486 \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
59 " 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
|
60 "1: \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
61 "pop %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
62 : "=r" (has_CPUID) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
63 : |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
64 : "%eax", "%ecx" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
65 ); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
66 #elif defined(_MSC_VER) |
749
06cdd106d61c
Updated Visual C++ support
Sam Lantinga <slouken@libsdl.org>
parents:
747
diff
changeset
|
67 __asm { |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
68 pushfd ; Get original EFLAGS |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
69 pop eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
70 mov ecx, eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
71 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
|
72 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
|
73 popfd ; Replace current EFLAGS value |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
74 pushfd ; Get new EFLAGS |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
75 pop eax ; Store new EFLAGS in EAX |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
76 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
|
77 jz done ; Processor=80486 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
78 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
|
79 done: |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
80 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
81 #endif |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
82 return has_CPUID; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
83 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
85 static __inline__ int CPU_getCPUIDFeatures() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
86 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
87 int features = 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
88 #if defined(__GNUC__) && defined(i386) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
89 __asm__ ( |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
90 "push %%ebx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
91 "push %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
92 "push %%edx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
93 " 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
|
94 " cpuid # Get and save vendor ID \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
95 " 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
|
96 " 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
|
97 " xorl %%eax,%%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
98 " incl %%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
99 " cpuid # Get family/model/stepping/features\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
100 " movl %%edx,%0 \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
101 "1: \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
102 "pop %%edx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
103 "pop %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
104 "pop %%ebx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
105 : "=r" (features) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
106 : |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
107 : "%eax", "%ebx", "%ecx", "%edx" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
108 ); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
109 #elif defined(_MSC_VER) |
749
06cdd106d61c
Updated Visual C++ support
Sam Lantinga <slouken@libsdl.org>
parents:
747
diff
changeset
|
110 __asm { |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
111 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
|
112 cpuid ; Get and save vendor ID |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
113 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
|
114 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
|
115 xor eax, eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
116 inc eax |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
117 cpuid ; Get family/model/stepping/features |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
118 mov features, edx |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
119 done: |
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 #endif |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
122 return features; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
123 } |
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 static __inline__ int CPU_haveRDTSC() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
126 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
127 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
128 return (CPU_getCPUIDFeatures() & 0x00000010); |
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 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
131 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
133 static __inline__ int CPU_haveMMX() |
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 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
136 return (CPU_getCPUIDFeatures() & 0x00800000); |
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 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
139 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
140 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
141 static __inline__ int CPU_have3DNow() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
142 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
143 int has_3DNow = 0; |
747
da36f59485da
Check for CPUID before checking for 3DNow!
Sam Lantinga <slouken@libsdl.org>
parents:
745
diff
changeset
|
144 if ( !CPU_haveCPUID() ) { |
da36f59485da
Check for CPUID before checking for 3DNow!
Sam Lantinga <slouken@libsdl.org>
parents:
745
diff
changeset
|
145 return 0; |
da36f59485da
Check for CPUID before checking for 3DNow!
Sam Lantinga <slouken@libsdl.org>
parents:
745
diff
changeset
|
146 } |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
147 #if defined(__GNUC__) && defined(i386) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
148 __asm__ ( |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
149 "push %%ebx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
150 "push %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
151 "push %%edx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
152 " 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
|
153 " cpuid # Get extended function limit \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
154 " cmpl $0x80000001,%%eax \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
155 " 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
|
156 " 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
|
157 " cpuid # and get the information \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
158 " 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
|
159 " 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
|
160 " 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
|
161 "1: \n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
162 "pop %%edx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
163 "pop %%ecx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
164 "pop %%ebx\n" |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
165 : "=r" (has_3DNow) |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
166 : |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
167 : "%eax", "%ebx", "%ecx", "%edx" |
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 #elif defined(_MSC_VER) |
749
06cdd106d61c
Updated Visual C++ support
Sam Lantinga <slouken@libsdl.org>
parents:
747
diff
changeset
|
170 __asm { |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
171 mov eax,80000000h ; Query for extended functions |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
172 cpuid ; Get extended function limit |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
173 cmp eax,80000001h |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
174 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
|
175 mov eax,80000001h ; Setup extended function 800000001h |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
176 cpuid ; and get the information |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
177 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
|
178 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
|
179 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
|
180 done: |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
181 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
182 #endif |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
183 return has_3DNow; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
184 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
185 |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
186 static __inline__ int CPU_haveSSE() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
187 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
188 if ( CPU_haveCPUID() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
189 return (CPU_getCPUIDFeatures() & 0x02000000); |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
190 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
191 return 0; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
192 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
194 static __inline__ int CPU_haveAltiVec() |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
195 { |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
196 #ifdef MACOSX |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
197 /* 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
|
198 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
|
199 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
|
200 */ |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
201 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
|
202 int hasVectorUnit = 0; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
203 size_t length = sizeof(hasVectorUnit); |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
204 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
|
205 if( 0 == error ) |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
206 return hasVectorUnit != 0; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
207 #endif |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
208 return 0; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
209 } |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
210 |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 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
|
212 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 static Uint32 SDL_GetCPUFeatures() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 if ( SDL_CPUFeatures == 0xFFFFFFFF ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 SDL_CPUFeatures = 0; |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
217 if ( CPU_haveRDTSC() ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
218 SDL_CPUFeatures |= CPU_HAS_RDTSC; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
219 } |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 if ( CPU_haveMMX() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 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
|
222 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 if ( CPU_have3DNow() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 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
|
225 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 if ( CPU_haveSSE() ) { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 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
|
228 } |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
229 if ( CPU_haveAltiVec() ) { |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
230 SDL_CPUFeatures |= CPU_HAS_ALTIVEC; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
231 } |
739
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 return SDL_CPUFeatures; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
236 SDL_bool SDL_HasRDTSC() |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
237 { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
238 if ( SDL_GetCPUFeatures() & CPU_HAS_RDTSC ) { |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
239 return SDL_TRUE; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
240 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
241 return SDL_FALSE; |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
242 } |
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
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 SDL_bool SDL_HasMMX() |
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 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
|
247 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 return SDL_FALSE; |
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 SDL_bool SDL_Has3DNow() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 { |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 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
|
255 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 return SDL_FALSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 } |
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 SDL_bool SDL_HasSSE() |
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 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
|
263 return SDL_TRUE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 return SDL_FALSE; |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 } |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
268 SDL_bool SDL_HasAltiVec() |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
269 { |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
270 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
|
271 return SDL_TRUE; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
272 } |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
273 return SDL_FALSE; |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
274 } |
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
275 |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 #ifdef TEST_MAIN |
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 #include <stdio.h> |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 int main() |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 { |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
282 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
|
283 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
|
284 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
|
285 printf("SSE: %d\n", SDL_HasSSE()); |
778
8ac3f46f9d09
Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
286 printf("AltiVec: %d\n", SDL_HasAltiVec()); |
745
71ee03909f42
Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents:
739
diff
changeset
|
287 return 0; |
739
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 |
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 #endif /* TEST_MAIN */ |