37 #define SDL_LIL_ENDIAN 1234
38 #define SDL_BIG_ENDIAN 4321
44 #define SDL_BYTEORDER __BYTE_ORDER
45 #elif defined(__OpenBSD__)
47 #define SDL_BYTEORDER BYTE_ORDER
49 #if defined(__hppa__) || \
50 defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
51 (defined(__MIPS__) && defined(__MIPSEB__)) || \
52 defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
54 #define SDL_BYTEORDER SDL_BIG_ENDIAN
56 #define SDL_BYTEORDER SDL_LIL_ENDIAN
71 #if defined(__GNUC__) && defined(__i386__) && \
72 !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 )
73 SDL_FORCE_INLINE Uint16
76 __asm__(
"xchgb %b0,%h0":
"=q"(x):
"0"(x));
79 #elif defined(__GNUC__) && defined(__x86_64__)
80 SDL_FORCE_INLINE Uint16
83 __asm__(
"xchgb %b0,%h0":
"=Q"(x):
"0"(x));
86 #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
87 SDL_FORCE_INLINE Uint16
92 __asm__(
"rlwimi %0,%2,8,16,23":
"=&r"(result):
"0"(x >> 8),
"r"(x));
93 return (Uint16)result;
95 #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
96 SDL_FORCE_INLINE Uint16
99 __asm__(
"rorw #8,%0":
"=d"(x):
"0"(x):
"cc");
102 #elif defined(__WATCOMC__) && defined(__386__)
103 extern _inline Uint16 SDL_Swap16(Uint16);
104 #pragma aux SDL_Swap16 = \
109 SDL_FORCE_INLINE Uint16
112 return SDL_static_cast(Uint16, ((x << 8) | (x >> 8)));
116 #if defined(__GNUC__) && defined(__i386__)
117 SDL_FORCE_INLINE Uint32
120 __asm__(
"bswap %0":
"=r"(x):
"0"(x));
123 #elif defined(__GNUC__) && defined(__x86_64__)
124 SDL_FORCE_INLINE Uint32
127 __asm__(
"bswapl %0":
"=r"(x):
"0"(x));
130 #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
131 SDL_FORCE_INLINE Uint32
136 __asm__(
"rlwimi %0,%2,24,16,23":
"=&r"(result):
"0"(x >> 24),
"r"(x));
137 __asm__(
"rlwimi %0,%2,8,8,15":
"=&r"(result):
"0"(result),
"r"(x));
138 __asm__(
"rlwimi %0,%2,24,0,7":
"=&r"(result):
"0"(result),
"r"(x));
141 #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
142 SDL_FORCE_INLINE Uint32
145 __asm__(
"rorw #8,%0\n\tswap %0\n\trorw #8,%0":
"=d"(x):
"0"(x):
"cc");
148 #elif defined(__WATCOMC__) && defined(__386__)
149 extern _inline Uint32 SDL_Swap32(Uint32);
151 #pragma aux SDL_Swap32 = \
156 #pragma aux SDL_Swap32 = \
164 SDL_FORCE_INLINE Uint32
167 return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) |
168 ((x >> 8) & 0x0000FF00) | (x >> 24)));
172 #if defined(__GNUC__) && defined(__i386__)
173 SDL_FORCE_INLINE Uint64
185 __asm__(
"bswapl %0 ; bswapl %1 ; xchgl %0,%1":
"=r"(v.s.a),
"=r"(v.s.b):
"0"(v.s.a),
190 #elif defined(__GNUC__) && defined(__x86_64__)
191 SDL_FORCE_INLINE Uint64
194 __asm__(
"bswapq %0":
"=r"(x):
"0"(x));
198 SDL_FORCE_INLINE Uint64
204 lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
206 hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
215 SDL_FORCE_INLINE
float
216 SDL_SwapFloat(
float x)
224 swapper.ui32 = SDL_Swap32(swapper.ui32);
234 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
235 #define SDL_SwapLE16(X) (X)
236 #define SDL_SwapLE32(X) (X)
237 #define SDL_SwapLE64(X) (X)
238 #define SDL_SwapFloatLE(X) (X)
239 #define SDL_SwapBE16(X) SDL_Swap16(X)
240 #define SDL_SwapBE32(X) SDL_Swap32(X)
241 #define SDL_SwapBE64(X) SDL_Swap64(X)
242 #define SDL_SwapFloatBE(X) SDL_SwapFloat(X)
244 #define SDL_SwapLE16(X) SDL_Swap16(X)
245 #define SDL_SwapLE32(X) SDL_Swap32(X)
246 #define SDL_SwapLE64(X) SDL_Swap64(X)
247 #define SDL_SwapFloatLE(X) SDL_SwapFloat(X)
248 #define SDL_SwapBE16(X) (X)
249 #define SDL_SwapBE32(X) (X)
250 #define SDL_SwapBE64(X) (X)
251 #define SDL_SwapFloatBE(X) (X)