Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef UT_ENDIAN_H
00025 #define UT_ENDIAN_H
00026
00027
00028 #ifdef CHECKED_ENDIANNESS
00029 # if defined(WORDS_BIGENDIAN)
00030 # define UT_BIG_ENDIAN
00031 # else
00032 # define UT_LITTLE_ENDIAN
00033 # endif
00034 #else
00035
00036 #if defined(__hpux)
00037
00038 #include <machine/param.h>
00039 #if defined(_BIG_ENDIAN)
00040 #define UT_BIG_ENDIAN
00041 #endif
00042 #if defined(_LITTLE_ENDIAN)
00043 #define UT_LITTLE_ENDIAN
00044 #endif
00045 #elif defined(__QNXNTO__)
00046 #include <sys/platform.h>
00047 #if defined(__LITTLEENDIAN__)
00048 #define UT_LITTLE_ENDIAN
00049 #else
00050 #define UT_BIG_ENDIAN
00051 #endif
00052 #elif defined(__FreeBSD__)
00053 #include <machine/endian.h>
00054 #if __BYTE_ORDER == __LITTLE_ENDIAN
00055 #define UT_LITTLE_ENDIAN
00056 #else
00057 #define UT_BIG_ENDIAN
00058 #endif
00059 #elif defined(__sgi)
00060 #include <sys/endian.h>
00061 #if BYTE_ORDER == LITTLE_ENDIAN
00062 #define UT_LITTLE_ENDIAN
00063 #else
00064 #define UT_BIG_ENDIAN
00065 #endif
00066 #elif defined(__MACH__) && defined(__APPLE__)
00067 #if defined(__BIG_ENDIAN__)
00068 #define UT_BIG_ENDIAN
00069 #else
00070 #define UT_LITTLE_ENDIAN
00071 #endif
00072 #elif defined(__sun)
00073 #include <sys/isa_defs.h>
00074 #if defined(_BIG_ENDIAN)
00075 #define UT_BIG_ENDIAN
00076 #elif defined(_LITTLE_ENDIAN)
00077 #define UT_LITTLE_ENDIAN
00078 #endif
00079 #elif defined(__NetBSD__) || defined(__OpenBSD__)
00080 #include <machine/endian.h>
00081 #if BYTE_ORDER == LITTLE_ENDIAN
00082 #define UT_LITTLE_ENDIAN
00083 #elif BYTE_ORDER == BIG_ENDIAN
00084 #define UT_BIG_ENDIAN
00085 #endif
00086 #elif defined(_AIX)
00087 #include <sys/machine.h>
00088 #if BYTE_ORDER == LITTLE_ENDIAN
00089 #define UT_LITTLE_ENDIAN
00090 #elif BYTE_ORDER == BIG_ENDIAN
00091 #define UT_BIG_ENDIAN
00092 #endif
00093 #elif defined(__osf__)
00094 #include <machine/endian.h>
00095 #if BYTE_ORDER == LITTLE_ENDIAN
00096 #define UT_LITTLE_ENDIAN
00097 #elif BYTE_ORDER == BIG_ENDIAN
00098 #define UT_BIG_ENDIAN
00099 #endif
00100 #elif defined(_WIN32)
00101
00102 #if !defined(UT_LITTLE_ENDIAN) && !defined(UT_BIG_ENDIAN)
00103 #define UT_LITTLE_ENDIAN
00104 #endif
00105 #else
00106 #include <endian.h>
00107 #if __BYTE_ORDER == __LITTLE_ENDIAN
00108 #define UT_LITTLE_ENDIAN
00109 #else
00110 #define UT_BIG_ENDIAN
00111 #endif
00112 #endif
00113 #endif
00114
00115
00116 #if defined(UT_BIG_ENDIAN)
00117 #elif defined(UT_LITTLE_ENDIAN)
00118 #else
00119 #error Must define UT_BIG_ENDIAN or UT_LITTLE_ENDIAN in ut_endian.h
00120 #endif
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 #ifdef UT_LITTLE_ENDIAN
00131 #define LE2BE16(x,y) \
00132 char * lb1; \
00133 UT_UCSChar tucs; \
00134 tucs = * ((UT_UCSChar *)(x)); lb1 = (char*) (&tucs); \
00135 *((char*)(y)) = *(lb1+1); *(((char*)(y)+1)) = *lb1;
00136 #else
00137 #define LE2BE16(x,y)
00138 #endif
00139
00140 #endif
00141