include/SDL_byteorder.h
changeset 1353 7ba544e2888d
parent 1312 c9b51268668f
child 1354 22f39393668a
equal deleted inserted replaced
1352:c643342f3f33 1353:7ba544e2888d
    23 /* Macros for determining the byte-order of this platform */
    23 /* Macros for determining the byte-order of this platform */
    24 
    24 
    25 #ifndef _SDL_byteorder_h
    25 #ifndef _SDL_byteorder_h
    26 #define _SDL_byteorder_h
    26 #define _SDL_byteorder_h
    27 
    27 
       
    28 #include "SDL_config.h"
       
    29 
    28 /* The two types of endianness */
    30 /* The two types of endianness */
    29 #define SDL_LIL_ENDIAN	1234
    31 #define SDL_LIL_ENDIAN	1234
    30 #define SDL_BIG_ENDIAN	4321
    32 #define SDL_BIG_ENDIAN	4321
    31 
    33 
    32 #ifdef __linux__
    34 #ifndef SDL_BYTEORDER	/* Not defined in SDL_config.h? */
    33 # include <endian.h>
       
    34 # if BYTE_ORDER == LITTLE_ENDIAN
       
    35 #  define SDL_BYTEORDER SDL_LIL_ENDIAN
       
    36 # else
       
    37 #  define SDL_BYTEORDER SDL_BIG_ENDIAN
       
    38 # endif
       
    39 
       
    40 #else
       
    41 
       
    42 /* Pardon the mess, I'm trying to determine the endianness of this host.
       
    43    I'm doing it by preprocessor defines rather than some sort of configure
       
    44    script so that application code can use this too.  The "right" way would
       
    45    be to dynamically generate this file on install, but that's a lot of work.
       
    46  */
       
    47 #if (defined(__i386__) || defined(__i386)) || \
    35 #if (defined(__i386__) || defined(__i386)) || \
    48      defined(__ia64__) || defined(WIN32) || \
    36      defined(__ia64__) || defined(__x86_64__) || \
    49     (defined(__alpha__) || defined(__alpha)) || \
    37     (defined(__alpha__) || defined(__alpha)) || \
    50     (defined(__arm__) || defined(__thumb__)) || \
    38     (defined(__arm__) || defined(__thumb__)) || \
    51     (defined(__sh__) || defined(__sh64__)) || \
    39     (defined(__sh__) || defined(__sh64__)) || \
    52     (defined(__mips__) && defined(__MIPSEL__)) || \
    40     (defined(__mips__) && defined(__MIPSEL__)) || \
    53      defined(__SYMBIAN32__) || defined(__x86_64__) || \
    41      defined(__SYMBIAN32__) || defined(__OS2__)
    54      defined(__OS2__) || defined(__LITTLE_ENDIAN__)
       
    55 #define SDL_BYTEORDER	SDL_LIL_ENDIAN
    42 #define SDL_BYTEORDER	SDL_LIL_ENDIAN
    56 #else
    43 #else
    57 #define SDL_BYTEORDER	SDL_BIG_ENDIAN
    44 #define SDL_BYTEORDER	SDL_BIG_ENDIAN
    58 #endif
    45 #endif
    59 
    46 #endif /* !SDL_BYTEORDER */
    60 #endif /* __linux__ */
       
    61 
    47 
    62 #endif /* _SDL_byteorder_h */
    48 #endif /* _SDL_byteorder_h */