Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
150 lines (126 loc) · 3.77 KB

SDL_cpuinfo.h

File metadata and controls

150 lines (126 loc) · 3.77 KB
 
Apr 8, 2011
Apr 8, 2011
2
3
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
Apr 8, 2011
Apr 8, 2011
5
6
7
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Apr 8, 2011
Apr 8, 2011
9
10
11
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
Apr 8, 2011
Apr 8, 2011
13
14
15
16
17
18
19
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jul 10, 2006
Jul 10, 2006
22
/**
Oct 19, 2009
Oct 19, 2009
23
24
25
* \file SDL_cpuinfo.h
*
* CPU feature detection for SDL.
Jul 10, 2006
Jul 10, 2006
26
*/
27
28
29
30
#ifndef _SDL_cpuinfo_h
#define _SDL_cpuinfo_h
Feb 21, 2006
Feb 21, 2006
31
32
#include "SDL_stdinc.h"
Feb 23, 2011
Feb 23, 2011
33
34
35
36
/* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE)
#include <intrin.h>
Mar 8, 2011
Mar 8, 2011
37
#ifndef _WIN64
Feb 23, 2011
Feb 23, 2011
38
39
#define __MMX__
#define __3dNOW__
Mar 8, 2011
Mar 8, 2011
40
#endif
Feb 23, 2011
Feb 23, 2011
41
42
43
44
45
#define __SSE__
#define __SSE2__
#elif defined(__MINGW64_VERSION_MAJOR)
#include <intrin.h>
#else
Feb 23, 2011
Feb 23, 2011
46
47
48
49
50
51
#ifdef __ALTIVEC__
#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
#include <altivec.h>
#undef pixel
#endif
#endif
Feb 23, 2011
Feb 23, 2011
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifdef __MMX__
#include <mmintrin.h>
#endif
#ifdef __3dNOW__
#include <mm3dnow.h>
#endif
#ifdef __SSE__
#include <xmmintrin.h>
#endif
#ifdef __SSE2__
#include <emmintrin.h>
#endif
#endif
66
67
68
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Jul 10, 2006
Jul 10, 2006
69
/* *INDENT-OFF* */
Jul 10, 2006
Jul 10, 2006
71
/* *INDENT-ON* */
Jan 28, 2011
Jan 28, 2011
74
75
76
77
/* This is a guess for the cacheline size used for padding.
* Most x86 processors have a 64 byte cache line.
* The 64-bit PowerPC processors have a 128 byte cache line.
* We'll use the larger value to be generally safe.
Jan 28, 2011
Jan 28, 2011
78
*/
Jan 28, 2011
Jan 28, 2011
79
#define SDL_CACHELINE_SIZE 128
Jan 28, 2011
Jan 28, 2011
80
Dec 16, 2009
Dec 16, 2009
81
82
83
84
85
/**
* This function returns the number of CPU cores available.
*/
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
Jan 28, 2011
Jan 28, 2011
86
87
88
89
90
91
92
93
/**
* This function returns the L1 cache line size of the CPU
*
* This is useful for determining multi-threaded structure padding
* or SIMD prefetch sizes.
*/
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
Oct 19, 2009
Oct 19, 2009
94
95
/**
* This function returns true if the CPU has the RDTSC instruction.
Nov 24, 2003
Nov 24, 2003
96
*/
Feb 24, 2006
Feb 24, 2006
97
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
Nov 24, 2003
Nov 24, 2003
98
Feb 23, 2011
Feb 23, 2011
99
100
101
102
103
/**
* This function returns true if the CPU has AltiVec features.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
Oct 19, 2009
Oct 19, 2009
104
105
/**
* This function returns true if the CPU has MMX features.
Feb 24, 2006
Feb 24, 2006
107
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
Feb 23, 2011
Feb 23, 2011
109
110
111
112
113
/**
* This function returns true if the CPU has 3DNow! features.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
Oct 19, 2009
Oct 19, 2009
114
115
/**
* This function returns true if the CPU has SSE features.
Feb 24, 2006
Feb 24, 2006
117
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
Oct 19, 2009
Oct 19, 2009
119
120
/**
* This function returns true if the CPU has SSE2 features.
Jan 24, 2004
Jan 24, 2004
121
*/
Feb 24, 2006
Feb 24, 2006
122
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
Jan 24, 2004
Jan 24, 2004
123
Oct 19, 2009
Oct 19, 2009
124
/**
Feb 11, 2011
Feb 11, 2011
125
126
127
128
129
* This function returns true if the CPU has SSE3 features.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
/**
Feb 12, 2011
Feb 12, 2011
130
* This function returns true if the CPU has SSE4.1 features.
Jan 6, 2004
Jan 6, 2004
131
*/
Feb 12, 2011
Feb 12, 2011
132
133
134
135
136
137
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
/**
* This function returns true if the CPU has SSE4.2 features.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
Feb 11, 2011
Feb 11, 2011
138
Jan 6, 2004
Jan 6, 2004
139
140
141
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
Jul 10, 2006
Jul 10, 2006
142
/* *INDENT-OFF* */
Jul 10, 2006
Jul 10, 2006
144
/* *INDENT-ON* */
145
146
147
148
#endif
#include "close_code.h"
#endif /* _SDL_cpuinfo_h */
Jul 10, 2006
Jul 10, 2006
149
150
/* vi: set ts=4 sw=4 expandtab: */