File: types.h

package info (click to toggle)
swftools 0.9.2%2Bgit20130725-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,680 kB
  • ctags: 17,348
  • sloc: ansic: 108,712; sh: 8,494; cpp: 8,040; yacc: 2,260; lisp: 904; makefile: 601; python: 300
file content (68 lines) | stat: -rw-r--r-- 1,943 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef __rfxtypes_h__
#define __rfxtypes_h__

#include "../config.h"

#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif

/* little/big endian stuff */

#define PUT8(ptr,x) {((U8*)(ptr))[0]=x;}
#define PUT16(ptr,x) {((U8*)(ptr))[0]=(U8)(x);((U8*)(ptr))[1]=(U8)((x)>>8);}
#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);}
#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) 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) SWAP16(s)
#define BE_32_TO_NATIVE(s) SWAP32(s)
#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	    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