37 #define SDL_LIL_ENDIAN 1234 38 #define SDL_BIG_ENDIAN 4321 44 #define SDL_BYTEORDER __BYTE_ORDER 46 #if defined(__hppa__) || \ 47 defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ 48 (defined(__MIPS__) && defined(__MISPEB__)) || \ 49 defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ 51 #define SDL_BYTEORDER SDL_BIG_ENDIAN 53 #define SDL_BYTEORDER SDL_LIL_ENDIAN 68 #if defined(__GNUC__) && defined(__i386__) && \ 69 !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 ) 70 SDL_FORCE_INLINE Uint16
73 __asm__(
"xchgb %b0,%h0":
"=q"(x):
"0"(x));
76 #elif defined(__GNUC__) && defined(__x86_64__) 77 SDL_FORCE_INLINE Uint16
80 __asm__(
"xchgb %b0,%h0":
"=Q"(x):
"0"(x));
83 #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 84 SDL_FORCE_INLINE Uint16
89 __asm__(
"rlwimi %0,%2,8,16,23":
"=&r"(result):
"0"(x >> 8),
"r"(x));
90 return (Uint16)result;
92 #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) 93 SDL_FORCE_INLINE Uint16
96 __asm__(
"rorw #8,%0":
"=d"(x):
"0"(x):
"cc");
99 #elif defined(__WATCOMC__) && defined(__386__) 100 extern _inline Uint16 SDL_Swap16(Uint16);
101 #pragma aux SDL_Swap16 = \ 106 SDL_FORCE_INLINE Uint16
109 return SDL_static_cast(Uint16, ((x << 8) | (x >> 8)));
113 #if defined(__GNUC__) && defined(__i386__) 114 SDL_FORCE_INLINE Uint32
117 __asm__(
"bswap %0":
"=r"(x):
"0"(x));
120 #elif defined(__GNUC__) && defined(__x86_64__) 121 SDL_FORCE_INLINE Uint32
124 __asm__(
"bswapl %0":
"=r"(x):
"0"(x));
127 #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 128 SDL_FORCE_INLINE Uint32
133 __asm__(
"rlwimi %0,%2,24,16,23":
"=&r"(result):
"0"(x >> 24),
"r"(x));
134 __asm__(
"rlwimi %0,%2,8,8,15":
"=&r"(result):
"0"(result),
"r"(x));
135 __asm__(
"rlwimi %0,%2,24,0,7":
"=&r"(result):
"0"(result),
"r"(x));
138 #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) 139 SDL_FORCE_INLINE Uint32
142 __asm__(
"rorw #8,%0\n\tswap %0\n\trorw #8,%0":
"=d"(x):
"0"(x):
"cc");
145 #elif defined(__WATCOMC__) && defined(__386__) 146 extern _inline Uint32 SDL_Swap32(Uint32);
148 #pragma aux SDL_Swap32 = \ 153 #pragma aux SDL_Swap32 = \ 161 SDL_FORCE_INLINE Uint32
164 return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) |
165 ((x >> 8) & 0x0000FF00) | (x >> 24)));
169 #if defined(__GNUC__) && defined(__i386__) 170 SDL_FORCE_INLINE Uint64
182 __asm__(
"bswapl %0 ; bswapl %1 ; xchgl %0,%1":
"=r"(v.s.a),
"=r"(v.s.b):
"0"(v.s.a),
187 #elif defined(__GNUC__) && defined(__x86_64__) 188 SDL_FORCE_INLINE Uint64
191 __asm__(
"bswapq %0":
"=r"(x):
"0"(x));
195 SDL_FORCE_INLINE Uint64
201 lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
203 hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
212 SDL_FORCE_INLINE
float 213 SDL_SwapFloat(
float x)
221 swapper.ui32 = SDL_Swap32(swapper.ui32);
231 #if SDL_BYTEORDER == SDL_LIL_ENDIAN 232 #define SDL_SwapLE16(X) (X) 233 #define SDL_SwapLE32(X) (X) 234 #define SDL_SwapLE64(X) (X) 235 #define SDL_SwapFloatLE(X) (X) 236 #define SDL_SwapBE16(X) SDL_Swap16(X) 237 #define SDL_SwapBE32(X) SDL_Swap32(X) 238 #define SDL_SwapBE64(X) SDL_Swap64(X) 239 #define SDL_SwapFloatBE(X) SDL_SwapFloat(X) 241 #define SDL_SwapLE16(X) SDL_Swap16(X) 242 #define SDL_SwapLE32(X) SDL_Swap32(X) 243 #define SDL_SwapLE64(X) SDL_Swap64(X) 244 #define SDL_SwapFloatLE(X) SDL_SwapFloat(X) 245 #define SDL_SwapBE16(X) (X) 246 #define SDL_SwapBE32(X) (X) 247 #define SDL_SwapBE64(X) (X) 248 #define SDL_SwapFloatBE(X) (X)