You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

189 rivejä
5.1 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_cpuinfo.h
  20. *
  21. * CPU feature detection for SDL.
  22. */
  23. #ifndef SDL_cpuinfo_h_
  24. #define SDL_cpuinfo_h_
  25. #include "SDL_stdinc.h"
  26. /* Need to do this here because intrin.h has C++ code in it */
  27. /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
  28. #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
  29. #ifdef __clang__
  30. /* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */
  31. #undef __MMX__
  32. #undef __SSE__
  33. #undef __SSE2__
  34. #else
  35. #include <intrin.h>
  36. #ifndef _WIN64
  37. #define __MMX__
  38. #define __3dNOW__
  39. #endif
  40. #define __SSE__
  41. #define __SSE2__
  42. #endif /* __clang__ */
  43. #elif defined(__MINGW64_VERSION_MAJOR)
  44. #include <intrin.h>
  45. #else
  46. #ifdef __ALTIVEC__
  47. #if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_ALTIVEC__) && !defined(SDL_DISABLE_ALTIVEC_H)
  48. #include <altivec.h>
  49. #undef pixel
  50. #undef bool
  51. #endif
  52. #endif
  53. #if defined(__ARM_NEON__) && !defined(SDL_DISABLE_ARM_NEON_H)
  54. #include <arm_neon.h>
  55. #endif
  56. #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
  57. #include <mm3dnow.h>
  58. #endif
  59. #if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
  60. #include <immintrin.h>
  61. #else
  62. #if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H)
  63. #include <mmintrin.h>
  64. #endif
  65. #if defined(__SSE__) && !defined(SDL_DISABLE_XMMINTRIN_H)
  66. #include <xmmintrin.h>
  67. #endif
  68. #if defined(__SSE2__) && !defined(SDL_DISABLE_EMMINTRIN_H)
  69. #include <emmintrin.h>
  70. #endif
  71. #if defined(__SSE3__) && !defined(SDL_DISABLE_PMMINTRIN_H)
  72. #include <pmmintrin.h>
  73. #endif
  74. #endif /* HAVE_IMMINTRIN_H */
  75. #endif /* compiler version */
  76. #include "begin_code.h"
  77. /* Set up for C function definitions, even when using C++ */
  78. #ifdef __cplusplus
  79. extern "C" {
  80. #endif
  81. /* This is a guess for the cacheline size used for padding.
  82. * Most x86 processors have a 64 byte cache line.
  83. * The 64-bit PowerPC processors have a 128 byte cache line.
  84. * We'll use the larger value to be generally safe.
  85. */
  86. #define SDL_CACHELINE_SIZE 128
  87. /**
  88. * This function returns the number of CPU cores available.
  89. */
  90. extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
  91. /**
  92. * This function returns the L1 cache line size of the CPU
  93. *
  94. * This is useful for determining multi-threaded structure padding
  95. * or SIMD prefetch sizes.
  96. */
  97. extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
  98. /**
  99. * This function returns true if the CPU has the RDTSC instruction.
  100. */
  101. extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
  102. /**
  103. * This function returns true if the CPU has AltiVec features.
  104. */
  105. extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
  106. /**
  107. * This function returns true if the CPU has MMX features.
  108. */
  109. extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
  110. /**
  111. * This function returns true if the CPU has 3DNow! features.
  112. */
  113. 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. * This function returns true if the CPU has SSE2 features.
  120. */
  121. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
  122. /**
  123. * This function returns true if the CPU has SSE3 features.
  124. */
  125. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
  126. /**
  127. * This function returns true if the CPU has SSE4.1 features.
  128. */
  129. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
  130. /**
  131. * This function returns true if the CPU has SSE4.2 features.
  132. */
  133. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
  134. /**
  135. * This function returns true if the CPU has AVX features.
  136. */
  137. extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
  138. /**
  139. * This function returns true if the CPU has AVX2 features.
  140. */
  141. extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
  142. /**
  143. * This function returns true if the CPU has AVX-512F (foundation) features.
  144. */
  145. extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void);
  146. /**
  147. * This function returns true if the CPU has NEON (ARM SIMD) features.
  148. */
  149. extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void);
  150. /**
  151. * This function returns the amount of RAM configured in the system, in MB.
  152. */
  153. extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
  154. /* Ends C function definitions when using C++ */
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #include "close_code.h"
  159. #endif /* SDL_cpuinfo_h_ */
  160. /* vi: set ts=4 sw=4 expandtab: */