comparison include/SDL_endian.h @ 4217:4c4113c2162c SDL-1.2

Fixed bug #706 Ken Bull 2009-02-25 13:22:02 PST Adds Doxygen support for all headers (except config and boilerplate headers) in the include folder for SDL-1.2 revision 4446. While in general SDL is quite thoroughly commented, none of these comments are correctly formatted for Doxygen and are generally inconsistent in their formatting.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 21 Sep 2009 09:38:10 +0000
parents a1b03ba2fcd0
children cd511a8560b7
comparison
equal deleted inserted replaced
4216:5b99971a27b4 4217:4c4113c2162c
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 22
23 /* Functions for reading and writing endian-specific values */ 23 /**
24 * @file SDL_endian.h
25 * Functions for reading and writing endian-specific values
26 */
24 27
25 #ifndef _SDL_endian_h 28 #ifndef _SDL_endian_h
26 #define _SDL_endian_h 29 #define _SDL_endian_h
27 30
28 #include "SDL_stdinc.h" 31 #include "SDL_stdinc.h"
29 32
30 /* The two types of endianness */ 33 /** @name SDL_ENDIANs
34 * The two types of endianness
35 */
36 /*@{*/
31 #define SDL_LIL_ENDIAN 1234 37 #define SDL_LIL_ENDIAN 1234
32 #define SDL_BIG_ENDIAN 4321 38 #define SDL_BIG_ENDIAN 4321
39 /*@}*/
33 40
34 #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ 41 #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
35 #if defined(__hppa__) || \ 42 #if defined(__hppa__) || \
36 defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ 43 defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
37 (defined(__MIPS__) && defined(__MISPEB__)) || \ 44 (defined(__MIPS__) && defined(__MISPEB__)) || \
48 /* Set up for C function definitions, even when using C++ */ 55 /* Set up for C function definitions, even when using C++ */
49 #ifdef __cplusplus 56 #ifdef __cplusplus
50 extern "C" { 57 extern "C" {
51 #endif 58 #endif
52 59
53 /* Use inline functions for compilers that support them, and static 60 /**
54 functions for those that do not. Because these functions become 61 * @name SDL_Swap Functions
55 static for compilers that do not support inline functions, this 62 * Use inline functions for compilers that support them, and static
56 header should only be included in files that actually use them. 63 * functions for those that do not. Because these functions become
57 */ 64 * static for compilers that do not support inline functions, this
65 * header should only be included in files that actually use them.
66 */
67 /*@{*/
58 #if defined(__GNUC__) && defined(__i386__) && \ 68 #if defined(__GNUC__) && defined(__i386__) && \
59 !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) 69 !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
60 static __inline__ Uint16 SDL_Swap16(Uint16 x) 70 static __inline__ Uint16 SDL_Swap16(Uint16 x)
61 { 71 {
62 __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x)); 72 __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x));
159 return(x); 169 return(x);
160 } 170 }
161 #endif 171 #endif
162 #else 172 #else
163 /* This is mainly to keep compilers from complaining in SDL code. 173 /* This is mainly to keep compilers from complaining in SDL code.
164 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
165 the fake 64-bit datatype that SDL provides when it compiles user code. 175 * the fake 64-bit datatype that SDL provides when it compiles user code.
166 */ 176 */
167 #define SDL_Swap64(X) (X) 177 #define SDL_Swap64(X) (X)
168 #endif /* SDL_HAS_64BIT_TYPE */ 178 #endif /* SDL_HAS_64BIT_TYPE */
169 179 /*@}*/
170 180
171 /* Byteswap item from the specified endianness to the native endianness */ 181 /**
182 * @name SDL_SwapLE and SDL_SwapBE Functions
183 * Byteswap item from the specified endianness to the native endianness
184 */
185 /*@{*/
172 #if SDL_BYTEORDER == SDL_LIL_ENDIAN 186 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
173 #define SDL_SwapLE16(X) (X) 187 #define SDL_SwapLE16(X) (X)
174 #define SDL_SwapLE32(X) (X) 188 #define SDL_SwapLE32(X) (X)
175 #define SDL_SwapLE64(X) (X) 189 #define SDL_SwapLE64(X) (X)
176 #define SDL_SwapBE16(X) SDL_Swap16(X) 190 #define SDL_SwapBE16(X) SDL_Swap16(X)
182 #define SDL_SwapLE64(X) SDL_Swap64(X) 196 #define SDL_SwapLE64(X) SDL_Swap64(X)
183 #define SDL_SwapBE16(X) (X) 197 #define SDL_SwapBE16(X) (X)
184 #define SDL_SwapBE32(X) (X) 198 #define SDL_SwapBE32(X) (X)
185 #define SDL_SwapBE64(X) (X) 199 #define SDL_SwapBE64(X) (X)
186 #endif 200 #endif
201 /*@}*/
187 202
188 /* Ends C function definitions when using C++ */ 203 /* Ends C function definitions when using C++ */
189 #ifdef __cplusplus 204 #ifdef __cplusplus
190 } 205 }
191 #endif 206 #endif