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 #ifdef WORDS_BIGENDIAN
22 #define SWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00))
23 #define SWAP32(s) (SWAP16(((s)>>16)&0x0000ffff)|((SWAP16(s)<<16)&0xffff0000))
24 #define REVERSESWAP16(x) (x)
25 #define REVERSESWAP32(x) (x)
29 #define REVERSESWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00))
30 #define REVERSESWAP32(s) (REVERSESWAP16(((s)>>16)&0x0000ffff)|((REVERSESWAP16(s)<<16)&0xffff0000))
35 #if SIZEOF_SIGNED_LONG_LONG != 8
36 #error "no way to define 64 bit integer"
38 #if SIZEOF_SIGNED != 4
39 #error "don't know how to define 32 bit integer"
41 #if SIZEOF_SIGNED_SHORT != 2
42 #error "don't know how to define 16 bit integer"
44 #if SIZEOF_SIGNED_CHAR != 1
45 #error "don't know how to define 8 bit integer"
48 typedef unsigned long long U64;
49 typedef signed long long S64;
52 typedef unsigned short U16;
53 typedef signed short S16;
54 typedef unsigned char U8;
55 typedef signed char S8;
57 #if SIZEOF_VOIDP == SIZEOF_SIGNED_LONG_LONG
58 typedef unsigned long long ptroff_t;
59 #elif SIZEOF_VOIDP == SIZEOF_SIGNED
60 typedef unsigned ptroff_t;
62 #error "Unknown pointer size"