00001
00002 #ifndef _STDINT_HXX
00003 #define _STDINT_HXX 1
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00038
00039
00040 #ifdef _MSC_VER
00041 typedef signed char int8_t;
00042 typedef signed short int16_t;
00043 typedef signed int int32_t;
00044 typedef signed __int64 int64_t;
00045 typedef unsigned char uint8_t;
00046 typedef unsigned short uint16_t;
00047 typedef unsigned int uint32_t;
00048 typedef unsigned __int64 uint64_t;
00049
00050 typedef int ssize_t;
00051 #elif defined(sgi) || defined(__sun)
00052 # include <sys/types.h>
00053 #else
00054 # include <stdint.h>
00055 #endif
00056
00057
00058 inline uint16_t sg_bswap_16(uint16_t x) {
00059 x = (x >> 8) | (x << 8);
00060 return x;
00061 }
00062
00063 inline uint32_t sg_bswap_32(uint32_t x) {
00064 x = ((x >> 8) & 0x00FF00FFL) | ((x << 8) & 0xFF00FF00L);
00065 x = (x >> 16) | (x << 16);
00066 return x;
00067 }
00068
00069 inline uint64_t sg_bswap_64(uint64_t x) {
00070 x = ((x >> 8) & 0x00FF00FF00FF00FFLL) | ((x << 8) & 0xFF00FF00FF00FF00LL);
00071 x = ((x >> 16) & 0x0000FFFF0000FFFFLL) | ((x << 16) & 0xFFFF0000FFFF0000LL);
00072 x = (x >> 32) | (x << 32);
00073 return x;
00074 }
00075
00076
00077 inline bool sgIsLittleEndian() {
00078 static const int sgEndianTest = 1;
00079 return (*((char *) &sgEndianTest ) != 0);
00080 }
00081
00082 inline bool sgIsBigEndian() {
00083 static const int sgEndianTest = 1;
00084 return (*((char *) &sgEndianTest ) == 0);
00085 }
00086
00087 inline void sgEndianSwap(uint16_t *x) { *x = sg_bswap_16(*x); }
00088 inline void sgEndianSwap(uint32_t *x) { *x = sg_bswap_32(*x); }
00089 inline void sgEndianSwap(uint64_t *x) { *x = sg_bswap_64(*x); }
00090
00091
00092
00093 #endif // !_STDINT_HXX
00094