This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_cpuinfo.h
150 lines (126 loc) · 3.77 KB
1
/*
2
3
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
4
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.
8
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:
12
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.
20
21
*/
22
/**
23
24
25
* \file SDL_cpuinfo.h
*
* CPU feature detection for SDL.
26
*/
27
28
29
30
#ifndef _SDL_cpuinfo_h
#define _SDL_cpuinfo_h
31
32
#include "SDL_stdinc.h"
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>
37
#ifndef _WIN64
38
39
#define __MMX__
#define __3dNOW__
40
#endif
41
42
43
44
45
#define __SSE__
#define __SSE2__
#elif defined(__MINGW64_VERSION_MAJOR)
#include <intrin.h>
#else
46
47
48
49
50
51
#ifdef __ALTIVEC__
#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
#include <altivec.h>
#undef pixel
#endif
#endif
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
69
/* *INDENT-OFF* */
70
extern "C" {
71
/* *INDENT-ON* */
72
73
#endif
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.
78
*/
79
#define SDL_CACHELINE_SIZE 128
80
81
82
83
84
85
/**
* This function returns the number of CPU cores available.
*/
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
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);
94
95
/**
* This function returns true if the CPU has the RDTSC instruction.
96
*/
97
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
98
99
100
101
102
103
/**
* This function returns true if the CPU has AltiVec features.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
104
105
/**
* This function returns true if the CPU has MMX features.
106
*/
107
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
108
109
110
111
112
113
/**
* This function returns true if the CPU has 3DNow! features.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
114
115
/**
* This function returns true if the CPU has SSE features.
116
*/
117
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
118
119
120
/**
* This function returns true if the CPU has SSE2 features.
121
*/
122
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
123
124
/**
125
126
127
128
129
* This function returns true if the CPU has SSE3 features.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
/**
130
* This function returns true if the CPU has SSE4.1 features.
131
*/
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);
138
139
140
141
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
142
/* *INDENT-OFF* */
143
}
144
/* *INDENT-ON* */
145
146
147
148
#endif
#include "close_code.h"
#endif /* _SDL_cpuinfo_h */
149
150
/* vi: set ts=4 sw=4 expandtab: */