SDL_endian.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. /**
  19. * # CategoryEndian
  20. *
  21. * Functions for reading and writing endian-specific values.
  22. */
  23. #ifndef SDL_endian_h_
  24. #define SDL_endian_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. #if defined(_MSC_VER) && (_MSC_VER >= 1400)
  27. /* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
  28. so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
  29. #ifdef __clang__
  30. #ifndef __PRFCHWINTRIN_H
  31. #define __PRFCHWINTRIN_H
  32. static __inline__ void __attribute__((__always_inline__, __nodebug__))
  33. _m_prefetch(void *__P)
  34. {
  35. __builtin_prefetch(__P, 0, 3 /* _MM_HINT_T0 */);
  36. }
  37. #endif /* __PRFCHWINTRIN_H */
  38. #endif /* __clang__ */
  39. #include <intrin.h>
  40. #endif
  41. /**
  42. * \name The two types of endianness
  43. */
  44. /* @{ */
  45. #define SDL_LIL_ENDIAN 1234
  46. #define SDL_BIG_ENDIAN 4321
  47. /* @} */
  48. #ifndef SDL_BYTEORDER
  49. #ifdef SDL_PLATFORM_LINUX
  50. #include <endian.h>
  51. #define SDL_BYTEORDER __BYTE_ORDER
  52. #elif defined(SDL_PLATFORM_SOLARIS)
  53. #include <sys/byteorder.h>
  54. #if defined(_LITTLE_ENDIAN)
  55. #define SDL_BYTEORDER SDL_LIL_ENDIAN
  56. #elif defined(_BIG_ENDIAN)
  57. #define SDL_BYTEORDER SDL_BIG_ENDIAN
  58. #else
  59. #error Unsupported endianness
  60. #endif
  61. #elif defined(SDL_PLATFORM_OPENBSD) || defined(__DragonFly__)
  62. #include <endian.h>
  63. #define SDL_BYTEORDER BYTE_ORDER
  64. #elif defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_NETBSD)
  65. #include <sys/endian.h>
  66. #define SDL_BYTEORDER BYTE_ORDER
  67. /* predefs from newer gcc and clang versions: */
  68. #elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__BYTE_ORDER__)
  69. #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  70. #define SDL_BYTEORDER SDL_LIL_ENDIAN
  71. #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  72. #define SDL_BYTEORDER SDL_BIG_ENDIAN
  73. #else
  74. #error Unsupported endianness
  75. #endif /**/
  76. #else
  77. #if defined(__hppa__) || \
  78. defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
  79. (defined(__MIPS__) && defined(__MIPSEB__)) || \
  80. defined(__ppc__) || defined(__POWERPC__) || defined(__powerpc__) || defined(__PPC__) || \
  81. defined(__sparc__) || defined(__sparc)
  82. #define SDL_BYTEORDER SDL_BIG_ENDIAN
  83. #else
  84. #define SDL_BYTEORDER SDL_LIL_ENDIAN
  85. #endif
  86. #endif /* SDL_PLATFORM_LINUX */
  87. #endif /* !SDL_BYTEORDER */
  88. #ifndef SDL_FLOATWORDORDER
  89. /* predefs from newer gcc versions: */
  90. #if defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__FLOAT_WORD_ORDER__)
  91. #if (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  92. #define SDL_FLOATWORDORDER SDL_LIL_ENDIAN
  93. #elif (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)
  94. #define SDL_FLOATWORDORDER SDL_BIG_ENDIAN
  95. #else
  96. #error Unsupported endianness
  97. #endif /**/
  98. #elif defined(__MAVERICK__)
  99. /* For Maverick, float words are always little-endian. */
  100. #define SDL_FLOATWORDORDER SDL_LIL_ENDIAN
  101. #elif (defined(__arm__) || defined(__thumb__)) && !defined(__VFP_FP__) && !defined(__ARM_EABI__)
  102. /* For FPA, float words are always big-endian. */
  103. #define SDL_FLOATWORDORDER SDL_BIG_ENDIAN
  104. #else
  105. /* By default, assume that floats words follow the memory system mode. */
  106. #define SDL_FLOATWORDORDER SDL_BYTEORDER
  107. #endif /* __FLOAT_WORD_ORDER__ */
  108. #endif /* !SDL_FLOATWORDORDER */
  109. #include <SDL3/SDL_begin_code.h>
  110. /* Set up for C function definitions, even when using C++ */
  111. #ifdef __cplusplus
  112. extern "C" {
  113. #endif
  114. /**
  115. * \file SDL_endian.h
  116. */
  117. /* various modern compilers may have builtin swap */
  118. #if defined(__GNUC__) || defined(__clang__)
  119. # define HAS_BUILTIN_BSWAP16 (SDL_HAS_BUILTIN(__builtin_bswap16)) || \
  120. (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
  121. # define HAS_BUILTIN_BSWAP32 (SDL_HAS_BUILTIN(__builtin_bswap32)) || \
  122. (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  123. # define HAS_BUILTIN_BSWAP64 (SDL_HAS_BUILTIN(__builtin_bswap64)) || \
  124. (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  125. /* this one is broken */
  126. # define HAS_BROKEN_BSWAP (__GNUC__ == 2 && __GNUC_MINOR__ <= 95)
  127. #else
  128. # define HAS_BUILTIN_BSWAP16 0
  129. # define HAS_BUILTIN_BSWAP32 0
  130. # define HAS_BUILTIN_BSWAP64 0
  131. # define HAS_BROKEN_BSWAP 0
  132. #endif
  133. /* Byte swap 16-bit integer. */
  134. #if HAS_BUILTIN_BSWAP16
  135. #define SDL_Swap16(x) __builtin_bswap16(x)
  136. #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
  137. #pragma intrinsic(_byteswap_ushort)
  138. #define SDL_Swap16(x) _byteswap_ushort(x)
  139. #elif defined(__i386__) && !HAS_BROKEN_BSWAP
  140. SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
  141. {
  142. __asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
  143. return x;
  144. }
  145. #elif defined(__x86_64__)
  146. SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
  147. {
  148. __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
  149. return x;
  150. }
  151. #elif (defined(__powerpc__) || defined(__ppc__))
  152. SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
  153. {
  154. int result;
  155. __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
  156. return (Uint16)result;
  157. }
  158. #elif (defined(__m68k__) && !defined(__mcoldfire__))
  159. SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
  160. {
  161. __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
  162. return x;
  163. }
  164. #elif defined(__WATCOMC__) && defined(__386__)
  165. extern __inline Uint16 SDL_Swap16(Uint16);
  166. #pragma aux SDL_Swap16 = \
  167. "xchg al, ah" \
  168. parm [ax] \
  169. modify [ax];
  170. #else
  171. SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
  172. {
  173. return SDL_static_cast(Uint16, ((x << 8) | (x >> 8)));
  174. }
  175. #endif
  176. /* Byte swap 32-bit integer. */
  177. #if HAS_BUILTIN_BSWAP32
  178. #define SDL_Swap32(x) __builtin_bswap32(x)
  179. #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
  180. #pragma intrinsic(_byteswap_ulong)
  181. #define SDL_Swap32(x) _byteswap_ulong(x)
  182. #elif defined(__i386__) && !HAS_BROKEN_BSWAP
  183. SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
  184. {
  185. __asm__("bswap %0": "=r"(x):"0"(x));
  186. return x;
  187. }
  188. #elif defined(__x86_64__)
  189. SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
  190. {
  191. __asm__("bswapl %0": "=r"(x):"0"(x));
  192. return x;
  193. }
  194. #elif (defined(__powerpc__) || defined(__ppc__))
  195. SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
  196. {
  197. Uint32 result;
  198. __asm__("rlwimi %0,%2,24,16,23": "=&r"(result): "0" (x>>24), "r"(x));
  199. __asm__("rlwimi %0,%2,8,8,15" : "=&r"(result): "0" (result), "r"(x));
  200. __asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x));
  201. return result;
  202. }
  203. #elif (defined(__m68k__) && !defined(__mcoldfire__))
  204. SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
  205. {
  206. __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc");
  207. return x;
  208. }
  209. #elif defined(__WATCOMC__) && defined(__386__)
  210. extern __inline Uint32 SDL_Swap32(Uint32);
  211. #pragma aux SDL_Swap32 = \
  212. "bswap eax" \
  213. parm [eax] \
  214. modify [eax];
  215. #else
  216. SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
  217. {
  218. return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) |
  219. ((x >> 8) & 0x0000FF00) | (x >> 24)));
  220. }
  221. #endif
  222. /* Byte swap 64-bit integer. */
  223. #if HAS_BUILTIN_BSWAP64
  224. #define SDL_Swap64(x) __builtin_bswap64(x)
  225. #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
  226. #pragma intrinsic(_byteswap_uint64)
  227. #define SDL_Swap64(x) _byteswap_uint64(x)
  228. #elif defined(__i386__) && !HAS_BROKEN_BSWAP
  229. SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x)
  230. {
  231. union {
  232. struct {
  233. Uint32 a, b;
  234. } s;
  235. Uint64 u;
  236. } v;
  237. v.u = x;
  238. __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
  239. : "=r"(v.s.a), "=r"(v.s.b)
  240. : "0" (v.s.a), "1"(v.s.b));
  241. return v.u;
  242. }
  243. #elif defined(__x86_64__)
  244. SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x)
  245. {
  246. __asm__("bswapq %0": "=r"(x):"0"(x));
  247. return x;
  248. }
  249. #elif defined(__WATCOMC__) && defined(__386__)
  250. extern __inline Uint64 SDL_Swap64(Uint64);
  251. #pragma aux SDL_Swap64 = \
  252. "bswap eax" \
  253. "bswap edx" \
  254. "xchg eax,edx" \
  255. parm [eax edx] \
  256. modify [eax edx];
  257. #else
  258. SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x)
  259. {
  260. Uint32 hi, lo;
  261. /* Separate into high and low 32-bit values and swap them */
  262. lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
  263. x >>= 32;
  264. hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
  265. x = SDL_Swap32(lo);
  266. x <<= 32;
  267. x |= SDL_Swap32(hi);
  268. return (x);
  269. }
  270. #endif
  271. /**
  272. * Byte-swap a floating point number.
  273. *
  274. * This will always byte-swap the value, whether it's currently in the native
  275. * byteorder of the system or not. You should use SDL_SwapFloatLE or
  276. * SDL_SwapFloatBE instead, in most cases.
  277. *
  278. * Note that this is a forced-inline function in a header, and not a public
  279. * API function available in the SDL library (which is to say, the code is
  280. * embedded in the calling program and the linker and dynamic loader will not
  281. * be able to find this function inside SDL itself).
  282. *
  283. * \param x the value to byte-swap.
  284. * \returns x, with its bytes in the opposite endian order.
  285. *
  286. * \threadsafety It is safe to call this function from any thread.
  287. *
  288. * \since This function is available since SDL 3.1.3.
  289. */
  290. SDL_FORCE_INLINE float SDL_SwapFloat(float x)
  291. {
  292. union {
  293. float f;
  294. Uint32 ui32;
  295. } swapper;
  296. swapper.f = x;
  297. swapper.ui32 = SDL_Swap32(swapper.ui32);
  298. return swapper.f;
  299. }
  300. /* remove extra macros */
  301. #undef HAS_BROKEN_BSWAP
  302. #undef HAS_BUILTIN_BSWAP16
  303. #undef HAS_BUILTIN_BSWAP32
  304. #undef HAS_BUILTIN_BSWAP64
  305. #ifdef SDL_WIKI_DOCUMENTATION_SECTION
  306. /**
  307. * Byte-swap an unsigned 16-bit number.
  308. *
  309. * This will always byte-swap the value, whether it's currently in the native
  310. * byteorder of the system or not. You should use SDL_Swap16LE or SDL_Swap16BE
  311. * instead, in most cases.
  312. *
  313. * Note that this is a forced-inline function in a header, and not a public
  314. * API function available in the SDL library (which is to say, the code is
  315. * embedded in the calling program and the linker and dynamic loader will not
  316. * be able to find this function inside SDL itself).
  317. *
  318. * \param x the value to byte-swap.
  319. * \returns `x`, with its bytes in the opposite endian order.
  320. *
  321. * \threadsafety It is safe to call this function from any thread.
  322. *
  323. * \since This function is available since SDL 3.1.3.
  324. */
  325. SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { return x_but_byteswapped; }
  326. /**
  327. * Byte-swap an unsigned 32-bit number.
  328. *
  329. * This will always byte-swap the value, whether it's currently in the native
  330. * byteorder of the system or not. You should use SDL_Swap32LE or SDL_Swap32BE
  331. * instead, in most cases.
  332. *
  333. * Note that this is a forced-inline function in a header, and not a public
  334. * API function available in the SDL library (which is to say, the code is
  335. * embedded in the calling program and the linker and dynamic loader will not
  336. * be able to find this function inside SDL itself).
  337. *
  338. * \param x the value to byte-swap.
  339. * \returns `x`, with its bytes in the opposite endian order.
  340. *
  341. * \threadsafety It is safe to call this function from any thread.
  342. *
  343. * \since This function is available since SDL 3.1.3.
  344. */
  345. SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { return x_but_byteswapped; }
  346. /**
  347. * Byte-swap an unsigned 64-bit number.
  348. *
  349. * This will always byte-swap the value, whether it's currently in the native
  350. * byteorder of the system or not. You should use SDL_Swap64LE or SDL_Swap64BE
  351. * instead, in most cases.
  352. *
  353. * Note that this is a forced-inline function in a header, and not a public
  354. * API function available in the SDL library (which is to say, the code is
  355. * embedded in the calling program and the linker and dynamic loader will not
  356. * be able to find this function inside SDL itself).
  357. *
  358. * \param x the value to byte-swap.
  359. * \returns `x`, with its bytes in the opposite endian order.
  360. *
  361. * \threadsafety It is safe to call this function from any thread.
  362. *
  363. * \since This function is available since SDL 3.1.3.
  364. */
  365. SDL_FORCE_INLINE Uint32 SDL_Swap64(Uint64 x) { return x_but_byteswapped; }
  366. /**
  367. * Swap a 16-bit value from littleendian to native byte order.
  368. *
  369. * If this is running on a littleendian system, `x` is returned unchanged.
  370. *
  371. * This macro never references `x` more than once, avoiding side effects.
  372. *
  373. * \param x the value to swap, in littleendian byte order.
  374. * \returns `x` in native byte order.
  375. *
  376. * \threadsafety It is safe to call this macro from any thread.
  377. *
  378. * \since This macro is available since SDL 3.1.3.
  379. */
  380. #define SDL_Swap16LE(x) SwapOnlyIfNecessary(x)
  381. /**
  382. * Swap a 32-bit value from littleendian to native byte order.
  383. *
  384. * If this is running on a littleendian system, `x` is returned unchanged.
  385. *
  386. * This macro never references `x` more than once, avoiding side effects.
  387. *
  388. * \param x the value to swap, in littleendian byte order.
  389. * \returns `x` in native byte order.
  390. *
  391. * \threadsafety It is safe to call this macro from any thread.
  392. *
  393. * \since This macro is available since SDL 3.1.3.
  394. */
  395. #define SDL_Swap32LE(x) SwapOnlyIfNecessary(x)
  396. /**
  397. * Swap a 64-bit value from littleendian to native byte order.
  398. *
  399. * If this is running on a littleendian system, `x` is returned unchanged.
  400. *
  401. * This macro never references `x` more than once, avoiding side effects.
  402. *
  403. * \param x the value to swap, in littleendian byte order.
  404. * \returns `x` in native byte order.
  405. *
  406. * \threadsafety It is safe to call this macro from any thread.
  407. *
  408. * \since This macro is available since SDL 3.1.3.
  409. */
  410. #define SDL_Swap64LE(x) SwapOnlyIfNecessary(x)
  411. /**
  412. * Swap a floating point value from littleendian to native byte order.
  413. *
  414. * If this is running on a littleendian system, `x` is returned unchanged.
  415. *
  416. * This macro never references `x` more than once, avoiding side effects.
  417. *
  418. * \param x the value to swap, in littleendian byte order.
  419. * \returns `x` in native byte order.
  420. *
  421. * \threadsafety It is safe to call this macro from any thread.
  422. *
  423. * \since This macro is available since SDL 3.1.3.
  424. */
  425. #define SDL_SwapFloatLE(x) SwapOnlyIfNecessary(x)
  426. /**
  427. * Swap a 16-bit value from bigendian to native byte order.
  428. *
  429. * If this is running on a bigendian system, `x` is returned unchanged.
  430. *
  431. * This macro never references `x` more than once, avoiding side effects.
  432. *
  433. * \param x the value to swap, in bigendian byte order.
  434. * \returns `x` in native byte order.
  435. *
  436. * \threadsafety It is safe to call this macro from any thread.
  437. *
  438. * \since This macro is available since SDL 3.1.3.
  439. */
  440. #define SDL_Swap16BE(x) SwapOnlyIfNecessary(x)
  441. /**
  442. * Swap a 32-bit value from bigendian to native byte order.
  443. *
  444. * If this is running on a bigendian system, `x` is returned unchanged.
  445. *
  446. * This macro never references `x` more than once, avoiding side effects.
  447. *
  448. * \param x the value to swap, in bigendian byte order.
  449. * \returns `x` in native byte order.
  450. *
  451. * \threadsafety It is safe to call this macro from any thread.
  452. *
  453. * \since This macro is available since SDL 3.1.3.
  454. */
  455. #define SDL_Swap32BE(x) SwapOnlyIfNecessary(x)
  456. /**
  457. * Swap a 64-bit value from bigendian to native byte order.
  458. *
  459. * If this is running on a bigendian system, `x` is returned unchanged.
  460. *
  461. * This macro never references `x` more than once, avoiding side effects.
  462. *
  463. * \param x the value to swap, in bigendian byte order.
  464. * \returns `x` in native byte order.
  465. *
  466. * \threadsafety It is safe to call this macro from any thread.
  467. *
  468. * \since This macro is available since SDL 3.1.3.
  469. */
  470. #define SDL_Swap64BE(x) SwapOnlyIfNecessary(x)
  471. /**
  472. * Swap a floating point value from bigendian to native byte order.
  473. *
  474. * If this is running on a bigendian system, `x` is returned unchanged.
  475. *
  476. * This macro never references `x` more than once, avoiding side effects.
  477. *
  478. * \param x the value to swap, in bigendian byte order.
  479. * \returns `x` in native byte order.
  480. *
  481. * \threadsafety It is safe to call this macro from any thread.
  482. *
  483. * \since This macro is available since SDL 3.1.3.
  484. */
  485. #define SDL_SwapFloatBE(x) SwapOnlyIfNecessary(x)
  486. #elif SDL_BYTEORDER == SDL_LIL_ENDIAN
  487. #define SDL_Swap16LE(x) (x)
  488. #define SDL_Swap32LE(x) (x)
  489. #define SDL_Swap64LE(x) (x)
  490. #define SDL_SwapFloatLE(x) (x)
  491. #define SDL_Swap16BE(x) SDL_Swap16(x)
  492. #define SDL_Swap32BE(x) SDL_Swap32(x)
  493. #define SDL_Swap64BE(x) SDL_Swap64(x)
  494. #define SDL_SwapFloatBE(x) SDL_SwapFloat(x)
  495. #else
  496. #define SDL_Swap16LE(x) SDL_Swap16(x)
  497. #define SDL_Swap32LE(x) SDL_Swap32(x)
  498. #define SDL_Swap64LE(x) SDL_Swap64(x)
  499. #define SDL_SwapFloatLE(x) SDL_SwapFloat(x)
  500. #define SDL_Swap16BE(x) (x)
  501. #define SDL_Swap32BE(x) (x)
  502. #define SDL_Swap64BE(x) (x)
  503. #define SDL_SwapFloatBE(x) (x)
  504. #endif
  505. /* Ends C function definitions when using C++ */
  506. #ifdef __cplusplus
  507. }
  508. #endif
  509. #include <SDL3/SDL_close_code.h>
  510. #endif /* SDL_endian_h_ */