Mercurial > sdl-ios-xcode
comparison include/SDL_endian.h @ 4431:d660ca4f7b1f SDL-1.2
Fixed bug 944
Tatu Kilappa 2010-02-11 12:13:20 PST
When compiling with -Wconversion, gcc complains about a cast in SDL_endian.h
that might change the result as we are casting from an int into an Uint16. This
is of course not visible unless we are on a non-x86 platform where the
assembler is not available.
While it's not really an error, the warning is really annoying. To fix, change
SDL_endian.h line 87 to:
return(Uint16)((x<<8)|(x>>8));
Thank you.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 13 Apr 2010 21:46:10 -0700 |
parents | 124629b76853 |
children | 7a53f8efc017 |
comparison
equal
deleted
inserted
replaced
4430:c40dae9695b1 | 4431:d660ca4f7b1f |
---|---|
92 __asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc"); | 92 __asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc"); |
93 return x; | 93 return x; |
94 } | 94 } |
95 #else | 95 #else |
96 static __inline__ Uint16 SDL_Swap16(Uint16 x) { | 96 static __inline__ Uint16 SDL_Swap16(Uint16 x) { |
97 return((x<<8)|(x>>8)); | 97 return (Uint16)((x<<8)|(x>>8)); |
98 } | 98 } |
99 #endif | 99 #endif |
100 | 100 |
101 #if defined(__GNUC__) && defined(__i386__) && \ | 101 #if defined(__GNUC__) && defined(__i386__) && \ |
102 !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) | 102 !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) |
127 __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc"); | 127 __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc"); |
128 return x; | 128 return x; |
129 } | 129 } |
130 #else | 130 #else |
131 static __inline__ Uint32 SDL_Swap32(Uint32 x) { | 131 static __inline__ Uint32 SDL_Swap32(Uint32 x) { |
132 return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)); | 132 return (Uint32)((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)); |
133 } | 133 } |
134 #endif | 134 #endif |
135 | 135 |
136 #ifdef SDL_HAS_64BIT_TYPE | 136 #ifdef SDL_HAS_64BIT_TYPE |
137 #if defined(__GNUC__) && defined(__i386__) && \ | 137 #if defined(__GNUC__) && defined(__i386__) && \ |
164 x >>= 32; | 164 x >>= 32; |
165 hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); | 165 hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); |
166 x = SDL_Swap32(lo); | 166 x = SDL_Swap32(lo); |
167 x <<= 32; | 167 x <<= 32; |
168 x |= SDL_Swap32(hi); | 168 x |= SDL_Swap32(hi); |
169 return(x); | 169 return (x); |
170 } | 170 } |
171 #endif | 171 #endif |
172 #else | 172 #else |
173 /* This is mainly to keep compilers from complaining in SDL code. | 173 /* This is mainly to keep compilers from complaining in SDL code. |
174 * If there is no real 64-bit datatype, then compilers will complain about | 174 * If there is no real 64-bit datatype, then compilers will complain about |