File: itypes.h

package info (click to toggle)
awesfx 0.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 784 kB
  • sloc: ansic: 6,532; sh: 56; makefile: 48
file content (44 lines) | stat: -rw-r--r-- 861 bytes parent folder | download | duplicates (6)
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
/*================================================================
 * integer types
 *================================================================*/

#ifndef ITYPES_H_DEF
#define ITYPES_H_DEF

/* 8bit bytes */
typedef signed char sbyte;
typedef unsigned char byte;

/* 16bit integers */
typedef unsigned short uint16;
typedef short int16;

/* 32bit long integers */
typedef unsigned int uint32;
typedef int int32;

/**/
typedef union uint32rec {
	byte b8[4];
	uint16 b16[4];
	uint32 b32;
} uint32rec;

/* vp=uint32rec, cp=char* */
#define get32rec(vp,cp) memcpy(vp, cp, 4)

#if 1
/* little endian */
#define swapi(x) x
#define swapl(x) x

#else
/* big endian */
#define swapi(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
#define swapl(x) ((((x)&0xFF)<<24) | \
		      (((x)&0xFF00)<<8) | \
		      (((x)&0xFF0000)>>8) | \
		      (((x)>>24)&0xFF))
#endif

#endif