kdtree code cleanup
[swftools.git] / lib / types.h
blob499c840b49d5554d2fff1617b0848459ba9ed93d
1 #ifndef __rfxtypes_h__
2 #define __rfxtypes_h__
4 #include "../config.h"
6 #ifndef TRUE
7 #define TRUE (1)
8 #endif
9 #ifndef FALSE
10 #define FALSE (0)
11 #endif
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)
29 #else
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)
34 #endif
36 // SWF Types
38 #if SIZEOF_SIGNED_LONG_LONG != 8
39 #error "no way to define 64 bit integer"
40 #endif
41 #if SIZEOF_SIGNED != 4
42 #error "don't know how to define 32 bit integer"
43 #endif
44 #if SIZEOF_SIGNED_SHORT != 2
45 #error "don't know how to define 16 bit integer"
46 #endif
47 #if SIZEOF_SIGNED_CHAR != 1
48 #error "don't know how to define 8 bit integer"
49 #endif
51 typedef unsigned long long U64;
52 typedef signed long long S64;
53 typedef unsigned U32;
54 typedef signed S32;
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;
64 #else
65 #error "Unknown pointer size"
66 #endif
68 #endif