comparison include/SDL_endian.h @ 1354:22f39393668a

Fixed build problem with SDL_string.c Officially deprecated SDL_byteorder.h, SDL_getenv.h and SDL_types.h Moved endian-related SDL_rwops code into SDL_rwops.c
author Sam Lantinga <slouken@libsdl.org>
date Thu, 09 Feb 2006 09:38:05 +0000
parents 7ba544e2888d
children 533567cbb576
comparison
equal deleted inserted replaced
1353:7ba544e2888d 1354:22f39393668a
23 /* Functions for reading and writing endian-specific values */ 23 /* Functions for reading and writing endian-specific values */
24 24
25 #ifndef _SDL_endian_h 25 #ifndef _SDL_endian_h
26 #define _SDL_endian_h 26 #define _SDL_endian_h
27 27
28 /* These functions read and write data of the specified endianness, 28 #include "SDL_stdinc.h"
29 dynamically translating to the host machine endianness.
30 29
31 e.g.: If you want to read a 16 bit value on big-endian machine from 30 /* The two types of endianness */
32 an open file containing little endian values, you would use: 31 #define SDL_LIL_ENDIAN 1234
33 value = SDL_ReadLE16(rp); 32 #define SDL_BIG_ENDIAN 4321
34 Note that the read/write functions use SDL_RWops pointers
35 instead of FILE pointers. This allows you to read and write
36 endian values from large chunks of memory as well as files
37 and other data sources.
38 */
39 33
40 #include "SDL_types.h" 34 #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
41 //#warning FIXME: move rwops into rwops and swapping into byteorder.h 35 #if (defined(__i386__) || defined(__i386)) || \
42 #include "SDL_rwops.h" 36 defined(__ia64__) || defined(__x86_64__) || \
43 #include "SDL_byteorder.h" 37 (defined(__alpha__) || defined(__alpha)) || \
38 (defined(__arm__) || defined(__thumb__)) || \
39 (defined(__sh__) || defined(__sh64__)) || \
40 (defined(__mips__) && defined(__MIPSEL__)) || \
41 defined(__SYMBIAN32__) || defined(__OS2__)
42 #define SDL_BYTEORDER SDL_LIL_ENDIAN
43 #else
44 #define SDL_BYTEORDER SDL_BIG_ENDIAN
45 #endif
46 #endif /* !SDL_BYTEORDER */
47
44 48
45 #include "begin_code.h" 49 #include "begin_code.h"
46 /* Set up for C function definitions, even when using C++ */ 50 /* Set up for C function definitions, even when using C++ */
47 #ifdef __cplusplus 51 #ifdef __cplusplus
48 extern "C" { 52 extern "C" {
178 #define SDL_SwapBE16(X) (X) 182 #define SDL_SwapBE16(X) (X)
179 #define SDL_SwapBE32(X) (X) 183 #define SDL_SwapBE32(X) (X)
180 #define SDL_SwapBE64(X) (X) 184 #define SDL_SwapBE64(X) (X)
181 #endif 185 #endif
182 186
183 /* Read an item of the specified endianness and return in native format */
184 extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
185 extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
186 extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
187 extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
188 extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
189 extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
190
191 /* Write an item of native format to the specified endianness */
192 extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
193 extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
194 extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
195 extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
196 extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
197 extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
198
199
200 /* Ends C function definitions when using C++ */ 187 /* Ends C function definitions when using C++ */
201 #ifdef __cplusplus 188 #ifdef __cplusplus
202 } 189 }
203 #endif 190 #endif
204 #include "close_code.h" 191 #include "close_code.h"