comparison include/SDL_endian.h @ 3407:d3baf5ac4e37

Partial fix for bug #859 Header file update from Ken for improved doxygen output
author Sam Lantinga <slouken@libsdl.org>
date Mon, 19 Oct 2009 13:31:58 +0000
parents bcd41b269091
children efb79807afe1
comparison
equal deleted inserted replaced
3406:8ae607392409 3407:d3baf5ac4e37
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 22
23 /** 23 /**
24 * \file SDL_endian.h 24 * \file SDL_endian.h
25 * 25 *
26 * Functions for reading and writing endian-specific values 26 * Functions for reading and writing endian-specific values
27 */ 27 */
28 28
29 #ifndef _SDL_endian_h 29 #ifndef _SDL_endian_h
30 #define _SDL_endian_h 30 #define _SDL_endian_h
31 31
32 #include "SDL_stdinc.h" 32 #include "SDL_stdinc.h"
33 33
34 /* The two types of endianness */ 34 /**
35 * \name The two types of endianness
36 */
37 /*@{*/
35 #define SDL_LIL_ENDIAN 1234 38 #define SDL_LIL_ENDIAN 1234
36 #define SDL_BIG_ENDIAN 4321 39 #define SDL_BIG_ENDIAN 4321
40 /*@}*/
37 41
38 #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ 42 #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
39 #if defined(__hppa__) || \ 43 #if defined(__hppa__) || \
40 defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ 44 defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
41 (defined(__MIPS__) && defined(__MISPEB__)) || \ 45 (defined(__MIPS__) && defined(__MISPEB__)) || \
54 /* *INDENT-OFF* */ 58 /* *INDENT-OFF* */
55 extern "C" { 59 extern "C" {
56 /* *INDENT-ON* */ 60 /* *INDENT-ON* */
57 #endif 61 #endif
58 62
59 /* Use inline functions for compilers that support them, and static 63 /**
60 functions for those that do not. Because these functions become 64 * \file SDL_endian.h
61 static for compilers that do not support inline functions, this 65 *
62 header should only be included in files that actually use them. 66 * Uses inline functions for compilers that support them, and static
63 */ 67 * functions for those that do not. Because these functions become
68 * static for compilers that do not support inline functions, this
69 * header should only be included in files that actually use them.
70 */
64 #if defined(__GNUC__) && defined(__i386__) && \ 71 #if defined(__GNUC__) && defined(__i386__) && \
65 !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) 72 !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
66 static __inline__ Uint16 73 static __inline__ Uint16
67 SDL_Swap16(Uint16 x) 74 SDL_Swap16(Uint16 x)
68 { 75 {
182 x |= SDL_Swap32(hi); 189 x |= SDL_Swap32(hi);
183 return (x); 190 return (x);
184 } 191 }
185 #endif 192 #endif
186 #else 193 #else
187 /* This is mainly to keep compilers from complaining in SDL code. 194 /**
188 If there is no real 64-bit datatype, then compilers will complain about 195 * This is mainly to keep compilers from complaining in SDL code.
189 the fake 64-bit datatype that SDL provides when it compiles user code. 196 * If there is no real 64-bit datatype, then compilers will complain about
190 */ 197 * the fake 64-bit datatype that SDL provides when it compiles user code.
198 */
191 #define SDL_Swap64(X) (X) 199 #define SDL_Swap64(X) (X)
192 #endif /* SDL_HAS_64BIT_TYPE */ 200 #endif /* SDL_HAS_64BIT_TYPE */
193 201
194 202
195 static __inline__ float 203 static __inline__ float
204 swapper.ui32 = SDL_Swap32(swapper.ui32); 212 swapper.ui32 = SDL_Swap32(swapper.ui32);
205 return swapper.f; 213 return swapper.f;
206 } 214 }
207 215
208 216
209 /* Byteswap item from the specified endianness to the native endianness */ 217 /**
218 * \name Swap to native
219 * Byteswap item from the specified endianness to the native endianness.
220 */
221 /*@{*/
210 #if SDL_BYTEORDER == SDL_LIL_ENDIAN 222 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
211 #define SDL_SwapLE16(X) (X) 223 #define SDL_SwapLE16(X) (X)
212 #define SDL_SwapLE32(X) (X) 224 #define SDL_SwapLE32(X) (X)
213 #define SDL_SwapLE64(X) (X) 225 #define SDL_SwapLE64(X) (X)
214 #define SDL_SwapFloatLE(X) (X) 226 #define SDL_SwapFloatLE(X) (X)
224 #define SDL_SwapBE16(X) (X) 236 #define SDL_SwapBE16(X) (X)
225 #define SDL_SwapBE32(X) (X) 237 #define SDL_SwapBE32(X) (X)
226 #define SDL_SwapBE64(X) (X) 238 #define SDL_SwapBE64(X) (X)
227 #define SDL_SwapFloatBE(X) (X) 239 #define SDL_SwapFloatBE(X) (X)
228 #endif 240 #endif
241 /*@}*//*Swap to native*/
229 242
230 /* Ends C function definitions when using C++ */ 243 /* Ends C function definitions when using C++ */
231 #ifdef __cplusplus 244 #ifdef __cplusplus
232 /* *INDENT-OFF* */ 245 /* *INDENT-OFF* */
233 } 246 }