19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*
29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    SDL - Simple DirectMedia Layer
39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 1997-2012 Sam Lantinga
49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is free software; you can redistribute it and/or
69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    modify it under the terms of the GNU Lesser General Public
79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License as published by the Free Software Foundation; either
89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    version 2.1 of the License, or (at your option) any later version.
99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is distributed in the hope that it will be useful,
119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    but WITHOUT ANY WARRANTY; without even the implied warranty of
129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Lesser General Public License for more details.
149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    You should have received a copy of the GNU Lesser General Public
169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License along with this library; if not, write to the Free Software
179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Sam Lantinga
209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    slouken@libsdl.org
219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/**
249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  @file SDL_endian.h
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  Functions for reading and writing endian-specific values
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _SDL_endian_h
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define _SDL_endian_h
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_stdinc.h"
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** @name SDL_ENDIANs
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  The two types of endianness
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@{*/
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_LIL_ENDIAN	1234
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_BIG_ENDIAN	4321
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@}*/
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef SDL_BYTEORDER	/* Not defined in SDL_config.h? */
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef __linux__
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <endian.h>
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_BYTEORDER  __BYTE_ORDER
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else /* __linux __ */
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__hppa__) || \
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    (defined(__MIPS__) && defined(__MISPEB__)) || \
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    defined(__sparc__)
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_BYTEORDER	SDL_BIG_ENDIAN
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_BYTEORDER	SDL_LIL_ENDIAN
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* __linux __ */
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* !SDL_BYTEORDER */
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "begin_code.h"
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Set up for C function definitions, even when using C++ */
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef __cplusplus
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" {
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/**
669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  @name SDL_Swap Functions
679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  Use inline functions for compilers that support them, and static
689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  functions for those that do not.  Because these functions become
699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  static for compilers that do not support inline functions, this
709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  header should only be included in files that actually use them.
719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */
729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@{*/
739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__GNUC__) && defined(__i386__) && \
749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall   !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint16 SDL_Swap16(Uint16 x)
769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("xchgb %b0,%h0" : "=q" (x) :  "0" (x));
789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return x;
799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#elif defined(__GNUC__) && defined(__x86_64__)
819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint16 SDL_Swap16(Uint16 x)
829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("xchgb %b0,%h0" : "=Q" (x) :  "0" (x));
849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return x;
859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint16 SDL_Swap16(Uint16 x)
889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int result;
909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x));
929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return (Uint16)result;
939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint16 SDL_Swap16(Uint16 x)
969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("rorw #8,%0" : "=d" (x) :  "0" (x) : "cc");
989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return x;
999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else
1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint16 SDL_Swap16(Uint16 x) {
1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return SDL_static_cast(Uint16, ((x<<8)|(x>>8)));
1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__GNUC__) && defined(__i386__) && \
1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall   !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint32 SDL_Swap32(Uint32 x)
1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("bswap %0" : "=r" (x) : "0" (x));
1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return x;
1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#elif defined(__GNUC__) && defined(__x86_64__)
1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint32 SDL_Swap32(Uint32 x)
1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("bswapl %0" : "=r" (x) : "0" (x));
1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return x;
1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint32 SDL_Swap32(Uint32 x)
1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	Uint32 result;
1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x));
1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("rlwimi %0,%2,8,8,15"   : "=&r" (result) : "0" (result),    "r" (x));
1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("rlwimi %0,%2,24,0,7"   : "=&r" (result) : "0" (result),    "r" (x));
1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return result;
1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint32 SDL_Swap32(Uint32 x)
1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) :  "0" (x) : "cc");
1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return x;
1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else
1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint32 SDL_Swap32(Uint32 x) {
1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return SDL_static_cast(Uint32, ((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)));
1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SDL_HAS_64BIT_TYPE
1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__GNUC__) && defined(__i386__) && \
1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall   !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint64 SDL_Swap64(Uint64 x)
1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	union {
1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		struct { Uint32 a,b; } s;
1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Uint64 u;
1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	} v;
1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	v.u = x;
1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	        : "=r" (v.s.a), "=r" (v.s.b)
1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	        : "0" (v.s.a), "1" (v.s.b));
1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return v.u;
1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#elif defined(__GNUC__) && defined(__x86_64__)
1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint64 SDL_Swap64(Uint64 x)
1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	__asm__("bswapq %0" : "=r" (x) : "0" (x));
1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return x;
1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else
1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic __inline__ Uint64 SDL_Swap64(Uint64 x)
1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	Uint32 hi, lo;
1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Separate into high and low 32-bit values and swap them */
1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	x >>= 32;
1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	x = SDL_Swap32(lo);
1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	x <<= 32;
1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	x |= SDL_Swap32(hi);
1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return (x);
1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else
1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* This is mainly to keep compilers from complaining in SDL code.
1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * If there is no real 64-bit datatype, then compilers will complain about
1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * the fake 64-bit datatype that SDL provides when it compiles user code.
1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */
1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_Swap64(X)	(X)
1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_HAS_64BIT_TYPE */
1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@}*/
1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/**
1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  @name SDL_SwapLE and SDL_SwapBE Functions
1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *  Byteswap item from the specified endianness to the native endianness
1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */
1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@{*/
1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_BYTEORDER == SDL_LIL_ENDIAN
1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapLE16(X)	(X)
1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapLE32(X)	(X)
1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapLE64(X)	(X)
1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapBE16(X)	SDL_Swap16(X)
1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapBE32(X)	SDL_Swap32(X)
1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapBE64(X)	SDL_Swap64(X)
1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else
1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapLE16(X)	SDL_Swap16(X)
2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapLE32(X)	SDL_Swap32(X)
2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapLE64(X)	SDL_Swap64(X)
2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapBE16(X)	(X)
2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapBE32(X)	(X)
2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_SwapBE64(X)	(X)
2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*@}*/
2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Ends C function definitions when using C++ */
2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef __cplusplus
2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "close_code.h"
2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* _SDL_endian_h */
215