include/SDL_endian.h
branchSDL-1.2
changeset 3909 6832b00d3594
parent 1475 d45aefcac017
child 4159 a1b03ba2fcd0
equal deleted inserted replaced
3908:6e41f5d80198 3909:6832b00d3594
    54    functions for those that do not.  Because these functions become
    54    functions for those that do not.  Because these functions become
    55    static for compilers that do not support inline functions, this
    55    static for compilers that do not support inline functions, this
    56    header should only be included in files that actually use them.
    56    header should only be included in files that actually use them.
    57 */
    57 */
    58 #if defined(__GNUC__) && defined(__i386__) && \
    58 #if defined(__GNUC__) && defined(__i386__) && \
    59    !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
    59    !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
    60 static __inline__ Uint16 SDL_Swap16(Uint16 x)
    60 static __inline__ Uint16 SDL_Swap16(Uint16 x)
    61 {
    61 {
    62 	__asm__("xchgb %b0,%h0" : "=q" (x) :  "0" (x));
    62 	__asm__("xchgb %b0,%h0" : "=q" (x) :  "0" (x));
    63 	return x;
    63 	return x;
    64 }
    64 }
    86 static __inline__ Uint16 SDL_Swap16(Uint16 x) {
    86 static __inline__ Uint16 SDL_Swap16(Uint16 x) {
    87 	return((x<<8)|(x>>8));
    87 	return((x<<8)|(x>>8));
    88 }
    88 }
    89 #endif
    89 #endif
    90 
    90 
    91 #if defined(__GNUC__) && defined(__i386__)
    91 #if defined(__GNUC__) && defined(__i386__) && \
       
    92    !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
    92 static __inline__ Uint32 SDL_Swap32(Uint32 x)
    93 static __inline__ Uint32 SDL_Swap32(Uint32 x)
    93 {
    94 {
    94 	__asm__("bswap %0" : "=r" (x) : "0" (x));
    95 	__asm__("bswap %0" : "=r" (x) : "0" (x));
    95 	return x;
    96 	return x;
    96 }
    97 }
   121 	return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24));
   122 	return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24));
   122 }
   123 }
   123 #endif
   124 #endif
   124 
   125 
   125 #ifdef SDL_HAS_64BIT_TYPE
   126 #ifdef SDL_HAS_64BIT_TYPE
   126 #if defined(__GNUC__) && defined(__i386__)
   127 #if defined(__GNUC__) && defined(__i386__) && \
       
   128    !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
   127 static __inline__ Uint64 SDL_Swap64(Uint64 x)
   129 static __inline__ Uint64 SDL_Swap64(Uint64 x)
   128 {
   130 {
   129 	union { 
   131 	union { 
   130 		struct { Uint32 a,b; } s;
   132 		struct { Uint32 a,b; } s;
   131 		Uint64 u;
   133 		Uint64 u;