X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Ftypes.h;h=499c840b49d5554d2fff1617b0848459ba9ed93d;hp=02fe287a540a2731a5ab75cbffc9c2ed68c6fcdd;hb=114fd977a15dcc7a9b52700279576cba80e6dc09;hpb=2bf2c4710c77705c21790b70a7a943456f1ced07 diff --git a/lib/types.h b/lib/types.h index 02fe287..499c840 100644 --- a/lib/types.h +++ b/lib/types.h @@ -18,16 +18,19 @@ #define GET16(ptr) (((U16)(((U8*)(ptr))[0]))+(((U16)(((U8*)(ptr))[1]))<<8)) #define GET32(ptr) (((U16)(((U8*)(ptr))[0]))+(((U16)(((U8*)(ptr))[1]))<<8)+(((U16)(((U8*)(ptr))[2]))<<16)+(((U16)(((U8*)(ptr))[3]))<<24)) +#define SWAP16(s) ((((s)>>8)&0x00ff)|(((s)<<8)&0xff00)) +#define SWAP32(s) (SWAP16(((s)>>16)&0x0000ffff)|((SWAP16(s)<<16)&0xffff0000)) + #ifdef WORDS_BIGENDIAN -#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 LE_16_TO_NATIVE(s) SWAP16(s) +#define LE_32_TO_NATIVE(s) SWAP32(s) #define BE_16_TO_NATIVE(x) (x) #define BE_32_TO_NATIVE(x) (x) #else #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)) +#define BE_16_TO_NATIVE(s) SWAP16(s) +#define BE_32_TO_NATIVE(s) SWAP32(s) #endif // SWF Types