X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Ftypes.h;h=02fe287a540a2731a5ab75cbffc9c2ed68c6fcdd;hp=ccc576d8dcc19057a00934eee52b76220b94422e;hb=2bf2c4710c77705c21790b70a7a943456f1ced07;hpb=cd3c954f7aa80b7388abe13e7ae9b924a1bb4953 diff --git a/lib/types.h b/lib/types.h index ccc576d..02fe287 100644 --- a/lib/types.h +++ b/lib/types.h @@ -1,6 +1,8 @@ #ifndef __rfxtypes_h__ #define __rfxtypes_h__ +#include "../config.h" + #ifndef TRUE #define TRUE (1) #endif @@ -17,26 +19,47 @@ #define GET32(ptr) (((U16)(((U8*)(ptr))[0]))+(((U16)(((U8*)(ptr))[1]))<<8)+(((U16)(((U8*)(ptr))[2]))<<16)+(((U16)(((U8*)(ptr))[3]))<<24)) #ifdef WORDS_BIGENDIAN -#define SWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00)) -#define SWAP32(s) (SWAP16(((s)>>16)&0x0000ffff)|((SWAP16(s)<<16)&0xffff0000)) -#define REVERSESWAP16(x) (x) -#define REVERSESWAP32(x) (x) +#define LE_16_TO_NATIVE(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00)) +#define LE_32_TO_NATIVE(s) (LE_16_TO_NATIVE(((s)>>16)&0x0000ffff)|((LE_16_TO_NATIVE(s)<<16)&0xffff0000)) +#define BE_16_TO_NATIVE(x) (x) +#define BE_32_TO_NATIVE(x) (x) #else -#define SWAP16(x) (x) -#define SWAP32(x) (x) -#define REVERSESWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00)) -#define REVERSESWAP32(s) (REVERSESWAP16(((s)>>16)&0x0000ffff)|((REVERSESWAP16(s)<<16)&0xffff0000)) +#define LE_16_TO_NATIVE(x) (x) +#define LE_32_TO_NATIVE(x) (x) +#define BE_16_TO_NATIVE(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00)) +#define BE_32_TO_NATIVE(s) (BE_16_TO_NATIVE(((s)>>16)&0x0000ffff)|((BE_16_TO_NATIVE(s)<<16)&0xffff0000)) #endif // SWF Types +#if SIZEOF_SIGNED_LONG_LONG != 8 +#error "no way to define 64 bit integer" +#endif +#if SIZEOF_SIGNED != 4 +#error "don't know how to define 32 bit integer" +#endif +#if SIZEOF_SIGNED_SHORT != 2 +#error "don't know how to define 16 bit integer" +#endif +#if SIZEOF_SIGNED_CHAR != 1 +#error "don't know how to define 8 bit integer" +#endif + typedef unsigned long long U64; typedef signed long long S64; -typedef unsigned long U32; -typedef signed long S32; +typedef unsigned U32; +typedef signed S32; typedef unsigned short U16; typedef signed short S16; typedef unsigned char U8; typedef signed char S8; +#if SIZEOF_VOIDP == SIZEOF_SIGNED_LONG_LONG +typedef unsigned long long ptroff_t; +#elif SIZEOF_VOIDP == SIZEOF_SIGNED +typedef unsigned ptroff_t; +#else +#error "Unknown pointer size" +#endif + #endif