SDL Library
Embed:
(wiki syntax)
Show/hide line numbers
SDL_cpuinfo.h
Go to the documentation of this file.
00001 /* 00002 Simple DirectMedia Layer 00003 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any damages 00007 arising from the use of this software. 00008 00009 Permission is granted to anyone to use this software for any purpose, 00010 including commercial applications, and to alter it and redistribute it 00011 freely, subject to the following restrictions: 00012 00013 1. The origin of this software must not be misrepresented; you must not 00014 claim that you wrote the original software. If you use this software 00015 in a product, an acknowledgment in the product documentation would be 00016 appreciated but is not required. 00017 2. Altered source versions must be plainly marked as such, and must not be 00018 misrepresented as being the original software. 00019 3. This notice may not be removed or altered from any source distribution. 00020 */ 00021 00022 /** 00023 * \file SDL_cpuinfo.h 00024 * 00025 * CPU feature detection for SDL. 00026 */ 00027 00028 #ifndef _SDL_cpuinfo_h 00029 #define _SDL_cpuinfo_h 00030 00031 #include "SDL_stdinc.h" 00032 00033 /* Need to do this here because intrin.h has C++ code in it */ 00034 /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ 00035 #if defined(_MSC_VER) && (_MSC_VER >= 1500) 00036 #include <intrin.h> 00037 #ifndef _WIN64 00038 #define __MMX__ 00039 #define __3dNOW__ 00040 #endif 00041 #define __SSE__ 00042 #define __SSE2__ 00043 #elif defined(__MINGW64_VERSION_MAJOR) 00044 #include <intrin.h> 00045 #else 00046 #ifdef __ALTIVEC__ 00047 #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) 00048 #include <altivec.h> 00049 #undef pixel 00050 #endif 00051 #endif 00052 #ifdef __MMX__ 00053 #include <mmintrin.h> 00054 #endif 00055 #ifdef __3dNOW__ 00056 #include <mm3dnow.h> 00057 #endif 00058 #ifdef __SSE__ 00059 #include <xmmintrin.h> 00060 #endif 00061 #ifdef __SSE2__ 00062 #include <emmintrin.h> 00063 #endif 00064 #endif 00065 00066 #include "begin_code.h" 00067 /* Set up for C function definitions, even when using C++ */ 00068 #ifdef __cplusplus 00069 extern "C" { 00070 #endif 00071 00072 /* This is a guess for the cacheline size used for padding. 00073 * Most x86 processors have a 64 byte cache line. 00074 * The 64-bit PowerPC processors have a 128 byte cache line. 00075 * We'll use the larger value to be generally safe. 00076 */ 00077 #define SDL_CACHELINE_SIZE 128 00078 00079 /** 00080 * This function returns the number of CPU cores available. 00081 */ 00082 extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); 00083 00084 /** 00085 * This function returns the L1 cache line size of the CPU 00086 * 00087 * This is useful for determining multi-threaded structure padding 00088 * or SIMD prefetch sizes. 00089 */ 00090 extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); 00091 00092 /** 00093 * This function returns true if the CPU has the RDTSC instruction. 00094 */ 00095 extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 00096 00097 /** 00098 * This function returns true if the CPU has AltiVec features. 00099 */ 00100 extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 00101 00102 /** 00103 * This function returns true if the CPU has MMX features. 00104 */ 00105 extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 00106 00107 /** 00108 * This function returns true if the CPU has 3DNow! features. 00109 */ 00110 extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 00111 00112 /** 00113 * This function returns true if the CPU has SSE features. 00114 */ 00115 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 00116 00117 /** 00118 * This function returns true if the CPU has SSE2 features. 00119 */ 00120 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 00121 00122 /** 00123 * This function returns true if the CPU has SSE3 features. 00124 */ 00125 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); 00126 00127 /** 00128 * This function returns true if the CPU has SSE4.1 features. 00129 */ 00130 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); 00131 00132 /** 00133 * This function returns true if the CPU has SSE4.2 features. 00134 */ 00135 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); 00136 00137 /** 00138 * This function returns true if the CPU has AVX features. 00139 */ 00140 extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); 00141 00142 /** 00143 * This function returns the amount of RAM configured in the system, in MB. 00144 */ 00145 extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); 00146 00147 00148 /* Ends C function definitions when using C++ */ 00149 #ifdef __cplusplus 00150 } 00151 #endif 00152 #include "close_code.h" 00153 00154 #endif /* _SDL_cpuinfo_h */ 00155 00156 /* vi: set ts=4 sw=4 expandtab: */
Generated on Tue Jul 12 2022 15:10:18 by 1.7.2