include/SDL_endian.h
changeset 1984 b910bcabec26
parent 1895 c121d94672cb
child 1985 8055185ae4ed
equal deleted inserted replaced
1983:ee73925ddf14 1984:b910bcabec26
   190 */
   190 */
   191 #define SDL_Swap64(X)	(X)
   191 #define SDL_Swap64(X)	(X)
   192 #endif /* SDL_HAS_64BIT_TYPE */
   192 #endif /* SDL_HAS_64BIT_TYPE */
   193 
   193 
   194 
   194 
       
   195 static __inline__ float
       
   196 SDL_SwapFloat(float x)
       
   197 {
       
   198     union { float f; Uint32 ui32; } swapper;
       
   199     swapper.f = x;
       
   200     swapper.ui32 = SDL_Swap32(swapper.ui32);
       
   201     return swapper.f;
       
   202 }
       
   203 
       
   204 
   195 /* Byteswap item from the specified endianness to the native endianness */
   205 /* Byteswap item from the specified endianness to the native endianness */
   196 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
   206 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
   197 #define SDL_SwapLE16(X)	(X)
   207 #define SDL_SwapLE16(X)	(X)
   198 #define SDL_SwapLE32(X)	(X)
   208 #define SDL_SwapLE32(X)	(X)
   199 #define SDL_SwapLE64(X)	(X)
   209 #define SDL_SwapLE64(X)	(X)
       
   210 #define SDL_SwapFloatLE(X)	(X)
   200 #define SDL_SwapBE16(X)	SDL_Swap16(X)
   211 #define SDL_SwapBE16(X)	SDL_Swap16(X)
   201 #define SDL_SwapBE32(X)	SDL_Swap32(X)
   212 #define SDL_SwapBE32(X)	SDL_Swap32(X)
   202 #define SDL_SwapBE64(X)	SDL_Swap64(X)
   213 #define SDL_SwapBE64(X)	SDL_Swap64(X)
       
   214 #define SDL_SwapFloatBE(X)	SDL_SwapFloat(X)
   203 #else
   215 #else
   204 #define SDL_SwapLE16(X)	SDL_Swap16(X)
   216 #define SDL_SwapLE16(X)	SDL_Swap16(X)
   205 #define SDL_SwapLE32(X)	SDL_Swap32(X)
   217 #define SDL_SwapLE32(X)	SDL_Swap32(X)
   206 #define SDL_SwapLE64(X)	SDL_Swap64(X)
   218 #define SDL_SwapLE64(X)	SDL_Swap64(X)
       
   219 #define SDL_SwapFloatLE(X)	SDL_SwapFloat(X)
   207 #define SDL_SwapBE16(X)	(X)
   220 #define SDL_SwapBE16(X)	(X)
   208 #define SDL_SwapBE32(X)	(X)
   221 #define SDL_SwapBE32(X)	(X)
   209 #define SDL_SwapBE64(X)	(X)
   222 #define SDL_SwapBE64(X)	(X)
       
   223 #define SDL_SwapFloatBE(X)	(X)
   210 #endif
   224 #endif
   211 
   225 
   212 /* Ends C function definitions when using C++ */
   226 /* Ends C function definitions when using C++ */
   213 #ifdef __cplusplus
   227 #ifdef __cplusplus
   214 /* *INDENT-OFF* */
   228 /* *INDENT-OFF* */