SDL_cpuinfo.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 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. /* WIKI CATEGORY: CPUInfo */
  19. /**
  20. * # CategoryCPUInfo
  21. *
  22. * CPU feature detection for SDL.
  23. *
  24. * These functions are largely concerned with reporting if the system has
  25. * access to various SIMD instruction sets, but also has other important info
  26. * to share, such as number of logical CPU cores.
  27. */
  28. #ifndef SDL_cpuinfo_h_
  29. #define SDL_cpuinfo_h_
  30. #include "SDL_stdinc.h"
  31. /* Need to do this here because intrin.h has C++ code in it */
  32. /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
  33. #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
  34. #ifdef __clang__
  35. /* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
  36. so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
  37. #ifndef __PRFCHWINTRIN_H
  38. #define __PRFCHWINTRIN_H
  39. static __inline__ void __attribute__((__always_inline__, __nodebug__))
  40. _m_prefetch(void *__P)
  41. {
  42. __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
  43. }
  44. #endif /* __PRFCHWINTRIN_H */
  45. #endif /* __clang__ */
  46. #include <intrin.h>
  47. #ifndef _WIN64
  48. #ifndef __MMX__
  49. #define __MMX__
  50. #endif
  51. #ifndef __3dNOW__
  52. #define __3dNOW__
  53. #endif
  54. #endif
  55. #ifndef __SSE__
  56. #define __SSE__
  57. #endif
  58. #ifndef __SSE2__
  59. #define __SSE2__
  60. #endif
  61. #ifndef __SSE3__
  62. #define __SSE3__
  63. #endif
  64. #elif defined(__MINGW64_VERSION_MAJOR)
  65. #include <intrin.h>
  66. #if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON)
  67. # include <arm_neon.h>
  68. #endif
  69. #else
  70. /* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */
  71. #if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
  72. #include <altivec.h>
  73. #endif
  74. #if !defined(SDL_DISABLE_ARM_NEON_H)
  75. # if defined(__ARM_NEON)
  76. # include <arm_neon.h>
  77. # elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
  78. /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
  79. # if defined(_M_ARM)
  80. # include <armintr.h>
  81. # include <arm_neon.h>
  82. # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
  83. # endif
  84. # if defined (_M_ARM64)
  85. # include <arm64intr.h>
  86. # include <arm64_neon.h>
  87. # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
  88. # define __ARM_ARCH 8
  89. # endif
  90. # endif
  91. #endif
  92. #endif /* compiler version */
  93. #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
  94. #include <mm3dnow.h>
  95. #endif
  96. #if defined(__loongarch_sx) && !defined(SDL_DISABLE_LSX_H)
  97. #include <lsxintrin.h>
  98. #define __LSX__
  99. #endif
  100. #if defined(__loongarch_asx) && !defined(SDL_DISABLE_LASX_H)
  101. #include <lasxintrin.h>
  102. #define __LASX__
  103. #endif
  104. #if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
  105. #include <immintrin.h>
  106. #else
  107. #if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H)
  108. #include <mmintrin.h>
  109. #endif
  110. #if defined(__SSE__) && !defined(SDL_DISABLE_XMMINTRIN_H)
  111. #include <xmmintrin.h>
  112. #endif
  113. #if defined(__SSE2__) && !defined(SDL_DISABLE_EMMINTRIN_H)
  114. #include <emmintrin.h>
  115. #endif
  116. #if defined(__SSE3__) && !defined(SDL_DISABLE_PMMINTRIN_H)
  117. #include <pmmintrin.h>
  118. #endif
  119. #endif /* HAVE_IMMINTRIN_H */
  120. #include "begin_code.h"
  121. /* Set up for C function definitions, even when using C++ */
  122. #ifdef __cplusplus
  123. extern "C" {
  124. #endif
  125. /* This is a guess for the cacheline size used for padding.
  126. * Most x86 processors have a 64 byte cache line.
  127. * The 64-bit PowerPC processors have a 128 byte cache line.
  128. * We'll use the larger value to be generally safe.
  129. */
  130. #define SDL_CACHELINE_SIZE 128
  131. /**
  132. * Get the number of CPU cores available.
  133. *
  134. * \returns the total number of logical CPU cores. On CPUs that include
  135. * technologies such as hyperthreading, the number of logical cores
  136. * may be more than the number of physical cores.
  137. *
  138. * \since This function is available since SDL 2.0.0.
  139. */
  140. extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
  141. /**
  142. * Determine the L1 cache line size of the CPU.
  143. *
  144. * This is useful for determining multi-threaded structure padding or SIMD
  145. * prefetch sizes.
  146. *
  147. * \returns the L1 cache line size of the CPU, in bytes.
  148. *
  149. * \since This function is available since SDL 2.0.0.
  150. */
  151. extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
  152. /**
  153. * Determine whether the CPU has the RDTSC instruction.
  154. *
  155. * This always returns false on CPUs that aren't using Intel instruction sets.
  156. *
  157. * \returns SDL_TRUE if the CPU has the RDTSC instruction or SDL_FALSE if not.
  158. *
  159. * \since This function is available since SDL 2.0.0.
  160. *
  161. * \sa SDL_Has3DNow
  162. * \sa SDL_HasAltiVec
  163. * \sa SDL_HasAVX
  164. * \sa SDL_HasAVX2
  165. * \sa SDL_HasMMX
  166. * \sa SDL_HasSSE
  167. * \sa SDL_HasSSE2
  168. * \sa SDL_HasSSE3
  169. * \sa SDL_HasSSE41
  170. * \sa SDL_HasSSE42
  171. */
  172. extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
  173. /**
  174. * Determine whether the CPU has AltiVec features.
  175. *
  176. * This always returns false on CPUs that aren't using PowerPC instruction
  177. * sets.
  178. *
  179. * \returns SDL_TRUE if the CPU has AltiVec features or SDL_FALSE if not.
  180. *
  181. * \since This function is available since SDL 2.0.0.
  182. *
  183. * \sa SDL_Has3DNow
  184. * \sa SDL_HasAVX
  185. * \sa SDL_HasAVX2
  186. * \sa SDL_HasMMX
  187. * \sa SDL_HasRDTSC
  188. * \sa SDL_HasSSE
  189. * \sa SDL_HasSSE2
  190. * \sa SDL_HasSSE3
  191. * \sa SDL_HasSSE41
  192. * \sa SDL_HasSSE42
  193. */
  194. extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
  195. /**
  196. * Determine whether the CPU has MMX features.
  197. *
  198. * This always returns false on CPUs that aren't using Intel instruction sets.
  199. *
  200. * \returns SDL_TRUE if the CPU has MMX features or SDL_FALSE if not.
  201. *
  202. * \since This function is available since SDL 2.0.0.
  203. *
  204. * \sa SDL_Has3DNow
  205. * \sa SDL_HasAltiVec
  206. * \sa SDL_HasAVX
  207. * \sa SDL_HasAVX2
  208. * \sa SDL_HasRDTSC
  209. * \sa SDL_HasSSE
  210. * \sa SDL_HasSSE2
  211. * \sa SDL_HasSSE3
  212. * \sa SDL_HasSSE41
  213. * \sa SDL_HasSSE42
  214. */
  215. extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
  216. /**
  217. * Determine whether the CPU has 3DNow! features.
  218. *
  219. * This always returns false on CPUs that aren't using AMD instruction sets.
  220. *
  221. * \returns SDL_TRUE if the CPU has 3DNow! features or SDL_FALSE if not.
  222. *
  223. * \since This function is available since SDL 2.0.0.
  224. *
  225. * \sa SDL_HasAltiVec
  226. * \sa SDL_HasAVX
  227. * \sa SDL_HasAVX2
  228. * \sa SDL_HasMMX
  229. * \sa SDL_HasRDTSC
  230. * \sa SDL_HasSSE
  231. * \sa SDL_HasSSE2
  232. * \sa SDL_HasSSE3
  233. * \sa SDL_HasSSE41
  234. * \sa SDL_HasSSE42
  235. */
  236. extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
  237. /**
  238. * Determine whether the CPU has SSE features.
  239. *
  240. * This always returns false on CPUs that aren't using Intel instruction sets.
  241. *
  242. * \returns SDL_TRUE if the CPU has SSE features or SDL_FALSE if not.
  243. *
  244. * \since This function is available since SDL 2.0.0.
  245. *
  246. * \sa SDL_Has3DNow
  247. * \sa SDL_HasAltiVec
  248. * \sa SDL_HasAVX
  249. * \sa SDL_HasAVX2
  250. * \sa SDL_HasMMX
  251. * \sa SDL_HasRDTSC
  252. * \sa SDL_HasSSE2
  253. * \sa SDL_HasSSE3
  254. * \sa SDL_HasSSE41
  255. * \sa SDL_HasSSE42
  256. */
  257. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
  258. /**
  259. * Determine whether the CPU has SSE2 features.
  260. *
  261. * This always returns false on CPUs that aren't using Intel instruction sets.
  262. *
  263. * \returns SDL_TRUE if the CPU has SSE2 features or SDL_FALSE if not.
  264. *
  265. * \since This function is available since SDL 2.0.0.
  266. *
  267. * \sa SDL_Has3DNow
  268. * \sa SDL_HasAltiVec
  269. * \sa SDL_HasAVX
  270. * \sa SDL_HasAVX2
  271. * \sa SDL_HasMMX
  272. * \sa SDL_HasRDTSC
  273. * \sa SDL_HasSSE
  274. * \sa SDL_HasSSE3
  275. * \sa SDL_HasSSE41
  276. * \sa SDL_HasSSE42
  277. */
  278. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
  279. /**
  280. * Determine whether the CPU has SSE3 features.
  281. *
  282. * This always returns false on CPUs that aren't using Intel instruction sets.
  283. *
  284. * \returns SDL_TRUE if the CPU has SSE3 features or SDL_FALSE if not.
  285. *
  286. * \since This function is available since SDL 2.0.0.
  287. *
  288. * \sa SDL_Has3DNow
  289. * \sa SDL_HasAltiVec
  290. * \sa SDL_HasAVX
  291. * \sa SDL_HasAVX2
  292. * \sa SDL_HasMMX
  293. * \sa SDL_HasRDTSC
  294. * \sa SDL_HasSSE
  295. * \sa SDL_HasSSE2
  296. * \sa SDL_HasSSE41
  297. * \sa SDL_HasSSE42
  298. */
  299. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
  300. /**
  301. * Determine whether the CPU has SSE4.1 features.
  302. *
  303. * This always returns false on CPUs that aren't using Intel instruction sets.
  304. *
  305. * \returns SDL_TRUE if the CPU has SSE4.1 features or SDL_FALSE if not.
  306. *
  307. * \since This function is available since SDL 2.0.0.
  308. *
  309. * \sa SDL_Has3DNow
  310. * \sa SDL_HasAltiVec
  311. * \sa SDL_HasAVX
  312. * \sa SDL_HasAVX2
  313. * \sa SDL_HasMMX
  314. * \sa SDL_HasRDTSC
  315. * \sa SDL_HasSSE
  316. * \sa SDL_HasSSE2
  317. * \sa SDL_HasSSE3
  318. * \sa SDL_HasSSE42
  319. */
  320. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
  321. /**
  322. * Determine whether the CPU has SSE4.2 features.
  323. *
  324. * This always returns false on CPUs that aren't using Intel instruction sets.
  325. *
  326. * \returns SDL_TRUE if the CPU has SSE4.2 features or SDL_FALSE if not.
  327. *
  328. * \since This function is available since SDL 2.0.0.
  329. *
  330. * \sa SDL_Has3DNow
  331. * \sa SDL_HasAltiVec
  332. * \sa SDL_HasAVX
  333. * \sa SDL_HasAVX2
  334. * \sa SDL_HasMMX
  335. * \sa SDL_HasRDTSC
  336. * \sa SDL_HasSSE
  337. * \sa SDL_HasSSE2
  338. * \sa SDL_HasSSE3
  339. * \sa SDL_HasSSE41
  340. */
  341. extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
  342. /**
  343. * Determine whether the CPU has AVX features.
  344. *
  345. * This always returns false on CPUs that aren't using Intel instruction sets.
  346. *
  347. * \returns SDL_TRUE if the CPU has AVX features or SDL_FALSE if not.
  348. *
  349. * \since This function is available since SDL 2.0.2.
  350. *
  351. * \sa SDL_Has3DNow
  352. * \sa SDL_HasAltiVec
  353. * \sa SDL_HasAVX2
  354. * \sa SDL_HasMMX
  355. * \sa SDL_HasRDTSC
  356. * \sa SDL_HasSSE
  357. * \sa SDL_HasSSE2
  358. * \sa SDL_HasSSE3
  359. * \sa SDL_HasSSE41
  360. * \sa SDL_HasSSE42
  361. */
  362. extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
  363. /**
  364. * Determine whether the CPU has AVX2 features.
  365. *
  366. * This always returns false on CPUs that aren't using Intel instruction sets.
  367. *
  368. * \returns SDL_TRUE if the CPU has AVX2 features or SDL_FALSE if not.
  369. *
  370. * \since This function is available since SDL 2.0.4.
  371. *
  372. * \sa SDL_Has3DNow
  373. * \sa SDL_HasAltiVec
  374. * \sa SDL_HasAVX
  375. * \sa SDL_HasMMX
  376. * \sa SDL_HasRDTSC
  377. * \sa SDL_HasSSE
  378. * \sa SDL_HasSSE2
  379. * \sa SDL_HasSSE3
  380. * \sa SDL_HasSSE41
  381. * \sa SDL_HasSSE42
  382. */
  383. extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
  384. /**
  385. * Determine whether the CPU has AVX-512F (foundation) features.
  386. *
  387. * This always returns false on CPUs that aren't using Intel instruction sets.
  388. *
  389. * \returns SDL_TRUE if the CPU has AVX-512F features or SDL_FALSE if not.
  390. *
  391. * \since This function is available since SDL 2.0.9.
  392. *
  393. * \sa SDL_HasAVX
  394. */
  395. extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void);
  396. /**
  397. * Determine whether the CPU has ARM SIMD (ARMv6) features.
  398. *
  399. * This is different from ARM NEON, which is a different instruction set.
  400. *
  401. * This always returns false on CPUs that aren't using ARM instruction sets.
  402. *
  403. * \returns SDL_TRUE if the CPU has ARM SIMD features or SDL_FALSE if not.
  404. *
  405. * \since This function is available since SDL 2.0.12.
  406. *
  407. * \sa SDL_HasNEON
  408. */
  409. extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void);
  410. /**
  411. * Determine whether the CPU has NEON (ARM SIMD) features.
  412. *
  413. * This always returns false on CPUs that aren't using ARM instruction sets.
  414. *
  415. * \returns SDL_TRUE if the CPU has ARM NEON features or SDL_FALSE if not.
  416. *
  417. * \since This function is available since SDL 2.0.6.
  418. */
  419. extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void);
  420. /**
  421. * Determine whether the CPU has LSX (LOONGARCH SIMD) features.
  422. *
  423. * This always returns false on CPUs that aren't using LOONGARCH instruction
  424. * sets.
  425. *
  426. * \returns SDL_TRUE if the CPU has LOONGARCH LSX features or SDL_FALSE if
  427. * not.
  428. *
  429. * \since This function is available since SDL 2.24.0.
  430. */
  431. extern DECLSPEC SDL_bool SDLCALL SDL_HasLSX(void);
  432. /**
  433. * Determine whether the CPU has LASX (LOONGARCH SIMD) features.
  434. *
  435. * This always returns false on CPUs that aren't using LOONGARCH instruction
  436. * sets.
  437. *
  438. * \returns SDL_TRUE if the CPU has LOONGARCH LASX features or SDL_FALSE if
  439. * not.
  440. *
  441. * \since This function is available since SDL 2.24.0.
  442. */
  443. extern DECLSPEC SDL_bool SDLCALL SDL_HasLASX(void);
  444. /**
  445. * Get the amount of RAM configured in the system.
  446. *
  447. * \returns the amount of RAM configured in the system in MiB.
  448. *
  449. * \since This function is available since SDL 2.0.1.
  450. */
  451. extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
  452. /**
  453. * Report the alignment this system needs for SIMD allocations.
  454. *
  455. * This will return the minimum number of bytes to which a pointer must be
  456. * aligned to be compatible with SIMD instructions on the current machine. For
  457. * example, if the machine supports SSE only, it will return 16, but if it
  458. * supports AVX-512F, it'll return 64 (etc). This only reports values for
  459. * instruction sets SDL knows about, so if your SDL build doesn't have
  460. * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and
  461. * not 64 for the AVX-512 instructions that exist but SDL doesn't know about.
  462. * Plan accordingly.
  463. *
  464. * \returns the alignment in bytes needed for available, known SIMD
  465. * instructions.
  466. *
  467. * \since This function is available since SDL 2.0.10.
  468. */
  469. extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void);
  470. /**
  471. * Allocate memory in a SIMD-friendly way.
  472. *
  473. * This will allocate a block of memory that is suitable for use with SIMD
  474. * instructions. Specifically, it will be properly aligned and padded for the
  475. * system's supported vector instructions.
  476. *
  477. * The memory returned will be padded such that it is safe to read or write an
  478. * incomplete vector at the end of the memory block. This can be useful so you
  479. * don't have to drop back to a scalar fallback at the end of your SIMD
  480. * processing loop to deal with the final elements without overflowing the
  481. * allocated buffer.
  482. *
  483. * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() or
  484. * delete[], etc.
  485. *
  486. * Note that SDL will only deal with SIMD instruction sets it is aware of; for
  487. * example, SDL 2.0.8 knows that SSE wants 16-byte vectors (SDL_HasSSE()), and
  488. * AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't know that AVX-512 wants
  489. * 64. To be clear: if you can't decide to use an instruction set with an
  490. * SDL_Has*() function, don't use that instruction set with memory allocated
  491. * through here.
  492. *
  493. * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't
  494. * out of memory, but you are not allowed to dereference it (because you only
  495. * own zero bytes of that buffer).
  496. *
  497. * \param len The length, in bytes, of the block to allocate. The actual
  498. * allocated block might be larger due to padding, etc.
  499. * \returns a pointer to the newly-allocated block, NULL if out of memory.
  500. *
  501. * \since This function is available since SDL 2.0.10.
  502. *
  503. * \sa SDL_SIMDGetAlignment
  504. * \sa SDL_SIMDRealloc
  505. * \sa SDL_SIMDFree
  506. */
  507. extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len);
  508. /**
  509. * Reallocate memory obtained from SDL_SIMDAlloc
  510. *
  511. * It is not valid to use this function on a pointer from anything but
  512. * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc,
  513. * SDL_malloc, memalign, new[], etc.
  514. *
  515. * \param mem The pointer obtained from SDL_SIMDAlloc. This function also
  516. * accepts NULL, at which point this function is the same as
  517. * calling SDL_SIMDAlloc with a NULL pointer.
  518. * \param len The length, in bytes, of the block to allocated. The actual
  519. * allocated block might be larger due to padding, etc. Passing 0
  520. * will return a non-NULL pointer, assuming the system isn't out of
  521. * memory.
  522. * \returns a pointer to the newly-reallocated block, NULL if out of memory.
  523. *
  524. * \since This function is available since SDL 2.0.14.
  525. *
  526. * \sa SDL_SIMDGetAlignment
  527. * \sa SDL_SIMDAlloc
  528. * \sa SDL_SIMDFree
  529. */
  530. extern DECLSPEC void * SDLCALL SDL_SIMDRealloc(void *mem, const size_t len);
  531. /**
  532. * Deallocate memory obtained from SDL_SIMDAlloc
  533. *
  534. * It is not valid to use this function on a pointer from anything but
  535. * SDL_SIMDAlloc() or SDL_SIMDRealloc(). It can't be used on pointers from
  536. * malloc, realloc, SDL_malloc, memalign, new[], etc.
  537. *
  538. * However, SDL_SIMDFree(NULL) is a legal no-op.
  539. *
  540. * The memory pointed to by `ptr` is no longer valid for access upon return,
  541. * and may be returned to the system or reused by a future allocation. The
  542. * pointer passed to this function is no longer safe to dereference once this
  543. * function returns, and should be discarded.
  544. *
  545. * \param ptr The pointer, returned from SDL_SIMDAlloc or SDL_SIMDRealloc, to
  546. * deallocate. NULL is a legal no-op.
  547. *
  548. * \since This function is available since SDL 2.0.10.
  549. *
  550. * \sa SDL_SIMDAlloc
  551. * \sa SDL_SIMDRealloc
  552. */
  553. extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr);
  554. /* Ends C function definitions when using C++ */
  555. #ifdef __cplusplus
  556. }
  557. #endif
  558. #include "close_code.h"
  559. #endif /* SDL_cpuinfo_h_ */
  560. /* vi: set ts=4 sw=4 expandtab: */