annotate src/cpuinfo/SDL_cpuinfo.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children c901fd2a42da
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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1229
diff changeset
3 Copyright (C) 1997-2006 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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1229
diff changeset
6 modify it under the terms of the GNU Lesser General Public
739
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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1229
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
739
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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1229
diff changeset
13 Lesser General Public License for more details.
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1229
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1229
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1229
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
739
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 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 /* 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
25
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
26 #include "SDL.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
27 #include "SDL_cpuinfo.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
28
1590
96d8c3fec479 Don't detect Altivec on MacOS X Intel
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
29 #if defined(__MACOSX__) && defined(__ppc__)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
30 #include <sys/sysctl.h> /* For AltiVec check */
1487
dc6b59e925a2 Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 1442
diff changeset
31 #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
793
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
32 #include <signal.h>
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
33 #include <setjmp.h>
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
34 #endif
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
35
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
36 #define CPU_HAS_RDTSC 0x00000001
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
37 #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
38 #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
39 #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
40 #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
41 #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
42 #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
43 #define CPU_HAS_ALTIVEC 0x00000100
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
44
1487
dc6b59e925a2 Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 1442
diff changeset
45 #if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__
793
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
46 /* This is the brute force way of detecting instruction sets...
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
47 the idea is borrowed from the libmpeg2 library - thanks!
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
48 */
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
49 static jmp_buf jmpbuf;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
50 static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
51 illegal_instruction(int sig)
793
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
52 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
53 longjmp(jmpbuf, 1);
793
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
54 }
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
55 #endif /* HAVE_SETJMP */
793
c20f08c4f437 Altivec detection on non-MacOS X systems
Sam Lantinga <slouken@libsdl.org>
parents: 787
diff changeset
56
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
57 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
58 CPU_haveCPUID(void)
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
59 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
60 int has_CPUID = 0;
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
61 #if defined(__GNUC__) && defined(i386)
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
62 __asm__(" pushfl # Get original EFLAGS \n" " popl %%eax \n" " movl %%eax,%%ecx \n" " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" " pushl %%eax # Save new EFLAGS value on stack \n" " popfl # Replace current EFLAGS value \n" " pushfl # Get new EFLAGS \n" " popl %%eax # Store new EFLAGS in EAX \n" " xorl %%ecx,%%eax # Can not toggle ID bit, \n" " jz 1f # Processor=80486 \n" " movl $1,%0 # We have CPUID support \n" "1: \n": "=m"(has_CPUID):
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
63 :"%eax", "%ecx");
881
9eb85a211abd Date: Tue, 30 Mar 2004 18:18:13 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 804
diff changeset
64 #elif defined(__GNUC__) && defined(__x86_64__)
9eb85a211abd Date: Tue, 30 Mar 2004 18:18:13 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 804
diff changeset
65 /* Technically, if this is being compiled under __x86_64__ then it has
9eb85a211abd Date: Tue, 30 Mar 2004 18:18:13 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 804
diff changeset
66 CPUid by definition. But it's nice to be able to prove it. :) */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
67 __asm__(" pushfq # Get original EFLAGS \n" " popq %%rax \n" " movq %%rax,%%rcx \n" " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" " pushq %%rax # Save new EFLAGS value on stack \n" " popfq # Replace current EFLAGS value \n" " pushfq # Get new EFLAGS \n" " popq %%rax # Store new EFLAGS in EAX \n" " xorl %%ecx,%%eax # Can not toggle ID bit, \n" " jz 1f # Processor=80486 \n" " movl $1,%0 # We have CPUID support \n" "1: \n": "=m"(has_CPUID):
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
68 :"%rax", "%rcx");
1442
e3242177fe4a Updated OS/2 build, yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1426
diff changeset
69 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
70 __asm {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
71 pushfd;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
72 Get original EFLAGS pop eax mov ecx, eax xor eax, 200000 h;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
73 Flip ID bit in EFLAGS push eax;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
74 Save new EFLAGS value on stack popfd;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
75 Replace current EFLAGS value pushfd;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
76 Get new EFLAGS pop eax;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
77 Store new EFLAGS in EAX xor eax, ecx;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
78 Can not toggle ID bit, jz done;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
79 Processor = 80486 mov has_CPUID, 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
80 We have CPUID support done:}
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
81 #elif defined(__sun) && defined(__x86)
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
82 __asm(" pushfl \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
83 " popl %eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
84 " movl %eax,%ecx \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
85 " xorl $0x200000,%eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
86 " pushl %eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
87 " popfl \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
88 " pushfl \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
89 " popl %eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
90 " xorl %ecx,%eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
91 " jz 1f \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
92 " movl $1,-8(%ebp) \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
93 "1: \n");
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
94 #elif defined(__sun) && defined(__amd64)
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
95 __asm(" pushfq \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
96 " popq %rax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
97 " movq %rax,%rcx \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
98 " xorl $0x200000,%eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
99 " pushq %rax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
100 " popfq \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
101 " pushfq \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
102 " popq %rax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
103 " xorl %ecx,%eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
104 " jz 1f \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
105 " movl $1,-8(%rbp) \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
106 "1: \n");
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
107 #endif
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
108 return has_CPUID;
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
109 }
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
111 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
112 CPU_getCPUIDFeatures(void)
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
113 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
114 int features = 0;
881
9eb85a211abd Date: Tue, 30 Mar 2004 18:18:13 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 804
diff changeset
115 #if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) )
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
116 __asm__(" movl %%ebx,%%edi\n" " xorl %%eax,%%eax # Set up for CPUID instruction \n" " cpuid # Get and save vendor ID \n" " cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n" " jl 1f # We dont have the CPUID instruction\n" " xorl %%eax,%%eax \n" " incl %%eax \n" " cpuid # Get family/model/stepping/features\n" " movl %%edx,%0 \n" "1: \n" " movl %%edi,%%ebx\n": "=m"(features):
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
117 :"%eax", "%ecx", "%edx", "%edi");
1442
e3242177fe4a Updated OS/2 build, yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1426
diff changeset
118 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
119 __asm {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
120 xor eax, eax;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
121 Set up for CPUID instruction
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
122 cpuid; Get and save vendor ID
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
123 cmp eax, 1; Make sure 1 is valid input for CPUID
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
124 jl done; We dont have the CPUID instruction
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
125 xor eax, eax
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
126 inc eax
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
127 cpuid; Get family / model / stepping / features
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
128 mov features, edx done:}
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
129 #elif defined(__sun) && (defined(__x86) || defined(__amd64))
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
130 __asm
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
131 (" movl %ebx,%edi\n"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
132 " xorl %eax,%eax \n"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
133 " cpuid \n"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
134 " cmpl $1,%eax \n"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
135 " jl 1f \n"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
136 " xorl %eax,%eax \n"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
137 " incl %eax \n"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
138 " cpuid \n"
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
139 #ifdef __i386
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
140 " movl %edx,-8(%ebp) \n"
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
141 #else
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
142 " movl %edx,-8(%rbp) \n"
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
143 #endif
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
144 "1: \n"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
145 " movl %edi,%ebx\n");
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
146 #endif
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
147 return features;
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
148 }
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
149
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
150 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
151 CPU_getCPUIDFeaturesExt(void)
785
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
152 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
153 int features = 0;
881
9eb85a211abd Date: Tue, 30 Mar 2004 18:18:13 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 804
diff changeset
154 #if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) )
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
155 __asm__(" movl %%ebx,%%edi\n" " movl $0x80000000,%%eax # Query for extended functions \n" " cpuid # Get extended function limit \n" " cmpl $0x80000001,%%eax \n" " jl 1f # Nope, we dont have function 800000001h\n" " movl $0x80000001,%%eax # Setup extended function 800000001h\n" " cpuid # and get the information \n" " movl %%edx,%0 \n" "1: \n" " movl %%edi,%%ebx\n": "=m"(features):
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
156 :"%eax", "%ecx", "%edx", "%edi");
1442
e3242177fe4a Updated OS/2 build, yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1426
diff changeset
157 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
158 __asm {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
159 mov eax, 80000000 h;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
160 Query for extended functions
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
161 cpuid; Get extended function limit
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
162 cmp eax, 80000001 h jl done; Nope
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
163 , we dont have function 800000001 h mov eax, 80000001 h;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
164 Setup extended function 800000001 h cpuid;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
165 and get the information mov features, edx done:}
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
166 #elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
167 __asm(" movl %ebx,%edi\n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
168 " movl $0x80000000,%eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
169 " cpuid \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
170 " cmpl $0x80000001,%eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
171 " jl 1f \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
172 " movl $0x80000001,%eax \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
173 " cpuid \n"
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
174 #ifdef __i386
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
175 " movl %edx,-8(%ebp) \n"
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
176 #else
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
177 " movl %edx,-8(%rbp) \n"
1229
1430f5fe092a Patch from Michael Bonfils to add CPUID support for x86 Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1198
diff changeset
178 #endif
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
179 "1: \n"
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
180 " movl %edi,%ebx\n");
785
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
181 #endif
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
182 return features;
785
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
183 }
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
184
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
185 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
186 CPU_haveRDTSC(void)
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
187 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
188 if (CPU_haveCPUID()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
189 return (CPU_getCPUIDFeatures() & 0x00000010);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
190 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
191 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
192 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
193
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
194 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
195 CPU_haveMMX(void)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
196 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
197 if (CPU_haveCPUID()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
198 return (CPU_getCPUIDFeatures() & 0x00800000);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
199 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
200 return 0;
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
201 }
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
203 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
204 CPU_haveMMXExt(void)
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
205 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
206 if (CPU_haveCPUID()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
207 return (CPU_getCPUIDFeaturesExt() & 0x00400000);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
208 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
209 return 0;
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
210 }
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
211
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
212 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
213 CPU_have3DNow(void)
785
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
214 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
215 if (CPU_haveCPUID()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
216 return (CPU_getCPUIDFeaturesExt() & 0x80000000);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
217 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
218 return 0;
785
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
219 }
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
220
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
221 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
222 CPU_have3DNowExt(void)
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
223 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
224 if (CPU_haveCPUID()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
225 return (CPU_getCPUIDFeaturesExt() & 0x40000000);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
226 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
227 return 0;
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
228 }
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
229
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
230 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
231 CPU_haveSSE(void)
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
232 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
233 if (CPU_haveCPUID()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
234 return (CPU_getCPUIDFeatures() & 0x02000000);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
235 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
236 return 0;
745
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
239 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
240 CPU_haveSSE2(void)
785
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
241 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
242 if (CPU_haveCPUID()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
243 return (CPU_getCPUIDFeatures() & 0x04000000);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
244 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
245 return 0;
785
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
246 }
ca06a994f03c Fixed bugs in CPU feature detection and added extended feature detection
Sam Lantinga <slouken@libsdl.org>
parents: 784
diff changeset
247
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
248 static __inline__ int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
249 CPU_haveAltiVec(void)
778
8ac3f46f9d09 Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
250 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
251 volatile int altivec = 0;
1590
96d8c3fec479 Don't detect Altivec on MacOS X Intel
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
252 #if defined(__MACOSX__) && defined(__ppc__)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
253 int selectors[2] = { CTL_HW, HW_VECTORUNIT };
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
254 int hasVectorUnit = 0;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
255 size_t length = sizeof(hasVectorUnit);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
256 int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
257 if (0 == error)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
258 altivec = (hasVectorUnit != 0);
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
259 #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
260 void (*handler) (int sig);
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
261 handler = signal(SIGILL, illegal_instruction);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
262 if (setjmp(jmpbuf) == 0) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
263 asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
264 altivec = 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
265 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
266 signal(SIGILL, handler);
778
8ac3f46f9d09 Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
267 #endif
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
268 return altivec;
778
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
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 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
272
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
273 static Uint32
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
274 SDL_GetCPUFeatures(void)
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
276 if (SDL_CPUFeatures == 0xFFFFFFFF) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
277 SDL_CPUFeatures = 0;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
278 if (CPU_haveRDTSC()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
279 SDL_CPUFeatures |= CPU_HAS_RDTSC;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
280 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
281 if (CPU_haveMMX()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
282 SDL_CPUFeatures |= CPU_HAS_MMX;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
283 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
284 if (CPU_haveMMXExt()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
285 SDL_CPUFeatures |= CPU_HAS_MMXEXT;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
286 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
287 if (CPU_have3DNow()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
288 SDL_CPUFeatures |= CPU_HAS_3DNOW;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
289 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
290 if (CPU_have3DNowExt()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
291 SDL_CPUFeatures |= CPU_HAS_3DNOWEXT;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
292 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
293 if (CPU_haveSSE()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
294 SDL_CPUFeatures |= CPU_HAS_SSE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
295 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
296 if (CPU_haveSSE2()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
297 SDL_CPUFeatures |= CPU_HAS_SSE2;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
298 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
299 if (CPU_haveAltiVec()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
300 SDL_CPUFeatures |= CPU_HAS_ALTIVEC;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
301 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
302 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
303 return SDL_CPUFeatures;
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 }
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
306 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
307 SDL_HasRDTSC(void)
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
308 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
309 if (SDL_GetCPUFeatures() & CPU_HAS_RDTSC) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
310 return SDL_TRUE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
311 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
312 return SDL_FALSE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
313 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
314
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
315 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
316 SDL_HasMMX(void)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
317 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
318 if (SDL_GetCPUFeatures() & CPU_HAS_MMX) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
319 return SDL_TRUE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
320 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
321 return SDL_FALSE;
745
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
322 }
71ee03909f42 Greatly simplified the SDL CPU info code
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
323
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
324 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
325 SDL_HasMMXExt(void)
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
327 if (SDL_GetCPUFeatures() & CPU_HAS_MMXEXT) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
328 return SDL_TRUE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
329 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
330 return SDL_FALSE;
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 }
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
333 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
334 SDL_Has3DNow(void)
804
b2fda076b02e *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 796
diff changeset
335 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
336 if (SDL_GetCPUFeatures() & CPU_HAS_3DNOW) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
337 return SDL_TRUE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
338 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
339 return SDL_FALSE;
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 }
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
342 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
343 SDL_Has3DNowExt(void)
804
b2fda076b02e *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 796
diff changeset
344 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
345 if (SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
346 return SDL_TRUE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
347 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
348 return SDL_FALSE;
804
b2fda076b02e *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 796
diff changeset
349 }
b2fda076b02e *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 796
diff changeset
350
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
351 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
352 SDL_HasSSE(void)
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
354 if (SDL_GetCPUFeatures() & CPU_HAS_SSE) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
355 return SDL_TRUE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
356 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
357 return SDL_FALSE;
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 }
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
360 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
361 SDL_HasSSE2(void)
804
b2fda076b02e *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 796
diff changeset
362 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
363 if (SDL_GetCPUFeatures() & CPU_HAS_SSE2) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
364 return SDL_TRUE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
365 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
366 return SDL_FALSE;
804
b2fda076b02e *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 796
diff changeset
367 }
b2fda076b02e *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 796
diff changeset
368
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
369 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
370 SDL_HasAltiVec(void)
778
8ac3f46f9d09 Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
371 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
372 if (SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
373 return SDL_TRUE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
374 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
375 return SDL_FALSE;
778
8ac3f46f9d09 Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
376 }
8ac3f46f9d09 Date: Tue, 6 Jan 2004 12:42:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
377
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 #ifdef TEST_MAIN
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 #include <stdio.h>
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
382 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
383 main()
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
385 printf("RDTSC: %d\n", SDL_HasRDTSC());
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
386 printf("MMX: %d\n", SDL_HasMMX());
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
387 printf("MMXExt: %d\n", SDL_HasMMXExt());
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
388 printf("3DNow: %d\n", SDL_Has3DNow());
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
389 printf("3DNowExt: %d\n", SDL_Has3DNowExt());
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
390 printf("SSE: %d\n", SDL_HasSSE());
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
391 printf("SSE2: %d\n", SDL_HasSSE2());
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
392 printf("AltiVec: %d\n", SDL_HasAltiVec());
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
393 return 0;
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 }
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 #endif /* TEST_MAIN */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1590
diff changeset
397 /* vi: set ts=4 sw=4 expandtab: */