13 /* little/big endian stuff */
15 #define PUT8(ptr,x) {((U8*)(ptr))[0]=x;}
16 #define PUT16(ptr,x) {((U8*)(ptr))[0]=(U8)(x);((U8*)(ptr))[1]=(U8)((x)>>8);}
17 #define PUT32(ptr,x) {((U8*)(ptr))[0]=(U8)(x);((U8*)(ptr))[1]=(U8)((x)>>8);((U8*)(ptr))[2]=(U8)((x)>>16);((U8*)(ptr))[3]=(U8)((x)>>24);}
18 #define GET16(ptr) (((U16)(((U8*)(ptr))[0]))+(((U16)(((U8*)(ptr))[1]))<<8))
19 #define GET32(ptr) (((U16)(((U8*)(ptr))[0]))+(((U16)(((U8*)(ptr))[1]))<<8)+(((U16)(((U8*)(ptr))[2]))<<16)+(((U16)(((U8*)(ptr))[3]))<<24))
21 #define SWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00))
22 #define SWAP32(s) (SWAP16(((s)>>16)&0x0000ffff)|((SWAP16(s)<<16)&0xffff0000))
24 #ifdef WORDS_BIGENDIAN
25 #define LE_16_TO_NATIVE(s) SWAP16(s)
26 #define LE_32_TO_NATIVE(s) SWAP32(s)
27 #define BE_16_TO_NATIVE(x) (x)
28 #define BE_32_TO_NATIVE(x) (x)
30 #define LE_16_TO_NATIVE(x) (x)
31 #define LE_32_TO_NATIVE(x) (x)
32 #define BE_16_TO_NATIVE(s) SWAP16(s)
33 #define BE_32_TO_NATIVE(s) SWAP32(s)
38 #if SIZEOF_SIGNED_LONG_LONG != 8
39 #error "no way to define 64 bit integer"
41 #if SIZEOF_SIGNED != 4
42 #error "don't know how to define 32 bit integer"
44 #if SIZEOF_SIGNED_SHORT != 2
45 #error "don't know how to define 16 bit integer"
47 #if SIZEOF_SIGNED_CHAR != 1
48 #error "don't know how to define 8 bit integer"
51 typedef unsigned long long U64
;
52 typedef signed long long S64
;
55 typedef unsigned short U16
;
56 typedef signed short S16
;
57 typedef unsigned char U8
;
58 typedef signed char S8
;
60 #if SIZEOF_VOIDP == SIZEOF_SIGNED_LONG_LONG
61 typedef unsigned long long ptroff_t
;
62 #elif SIZEOF_VOIDP == SIZEOF_SIGNED
63 typedef unsigned ptroff_t
;
65 #error "Unknown pointer size"