replaced libart with new polygon code
[swftools.git] / lib / types.h
1 #ifndef __rfxtypes_h__
2 #define __rfxtypes_h__
3
4 #include "../config.h"
5
6 #ifndef TRUE
7 #define TRUE (1)
8 #endif
9 #ifndef FALSE
10 #define FALSE (0)
11 #endif
12
13 /* little/big endian stuff */
14
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))
20
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)
26 #else
27 #define SWAP16(x) (x)
28 #define SWAP32(x) (x)
29 #define REVERSESWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00))
30 #define REVERSESWAP32(s) (REVERSESWAP16(((s)>>16)&0x0000ffff)|((REVERSESWAP16(s)<<16)&0xffff0000))
31 #endif
32
33 // SWF Types
34
35 #if SIZEOF_SIGNED_LONG_LONG != 8
36 #error "no way to define 64 bit integer"
37 #endif
38 #if SIZEOF_SIGNED != 4
39 #error "don't know how to define 32 bit integer"
40 #endif
41 #if SIZEOF_SIGNED_SHORT != 2
42 #error "don't know how to define 16 bit integer"
43 #endif
44 #if SIZEOF_SIGNED_CHAR != 1
45 #error "don't know how to define 8 bit integer"
46 #endif
47
48 typedef         unsigned long long  U64;
49 typedef         signed long long    S64;
50 typedef         unsigned            U32;
51 typedef         signed              S32;
52 typedef         unsigned short      U16;
53 typedef         signed short        S16;
54 typedef         unsigned char       U8;
55 typedef         signed char         S8;
56
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;
61 #else
62 #error "Unknown pointer size"
63 #endif
64
65 #endif