endian-c.h

Go to the documentation of this file.
00001 
00024 #ifndef HT_ENDIAN_C_H
00025 #define HT_ENDIAN_C_H
00026 
00027 /* GNU libc offers the helpful header <endian.h> which defines __BYTE_ORDER */
00028 #if defined (__GLIBC__)
00029 # include <endian.h>
00030 # if (__BYTE_ORDER == __LITTLE_ENDIAN)
00031 #  define HT_LITTLE_ENDIAN
00032 # elif (__BYTE_ORDER == __BIG_ENDIAN)
00033 #  define HT_BIG_ENDIAN
00034 # elif (__BYTE_ORDER == __PDP_ENDIAN)
00035 #  define HT_PDP_ENDIAN
00036 # else
00037 #  error Unknown machine endianness detected.
00038 # endif
00039 # define HT_BYTE_ORDER __BYTE_ORDER
00040 #elif defined(__sparc) || defined(__sparc__) \
00041    || defined(_POWER) || defined(__powerpc__) \
00042    || defined(__ppc__) || defined(__hpux) \
00043    || defined(_MIPSEB) || defined(_POWER) \
00044    || defined(__s390__)
00045 # define HT_BIG_ENDIAN
00046 # define HT_BYTE_ORDER 4321
00047 #elif defined(__i386__) || defined(__alpha__) \
00048    || defined(__ia64) || defined(__ia64__) \
00049    || defined(_M_IX86) || defined(_M_IA64) \
00050    || defined(_M_ALPHA) || defined(__amd64) \
00051    || defined(__amd64__) || defined(_M_AMD64) \
00052    || defined(__x86_64) || defined(__x86_64__) \
00053    || defined(_M_X64)
00054 
00055 # define HT_LITTLE_ENDIAN
00056 # define HT_BYTE_ORDER 1234
00057 #else
00058 # error The file Common/endian.h needs to be set up for your CPU type.
00059 #endif
00060 
00061 #endif /* HT_ENDIAN_C_H */