-
Notifications
You must be signed in to change notification settings - Fork 13
/
types.h
108 lines (87 loc) · 3.17 KB
/
types.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
Copyright 2012 Dynastream Innovations, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#if !defined(TYPES_H)
#define TYPES_H
#define LITTLE_ENDIAN
#if defined(PC_SIM)
#include <windows.h>
#endif
//////////////////////////////////////////////////////////////////////////////////
// Public Definitions
//////////////////////////////////////////////////////////////////////////////////
#define TRUE 1
#define FALSE 0
#if !defined(NULL)
#define NULL ((void *) 0)
#endif
#define MAX_UCHAR 0xFF
#define MAX_SCHAR 0x7F
#define MIN_SCHAR 0x80
#define MAX_SHORT 0x7FFF
#define MIN_SHORT 0x8000
#define MAX_USHORT 0xFFFF
#define MAX_SSHORT 0x7FFF
#define MIN_SSHORT 0x8000
#define MAX_LONG 0x7FFFFFFF
#define MIN_LONG 0x80000000
#define MAX_ULONG 0xFFFFFFFF
#define MAX_SLONG 0x7FFFFFFF
#define MIN_SLONG 0x80000000
#if !defined(BASETYPES) // windef.h compatibility
typedef unsigned char BOOL;
#endif
typedef unsigned char UCHAR;
typedef signed char SCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef signed short SSHORT;
#if !defined(LONG)
typedef long LONG;
#endif
typedef unsigned long ULONG;
typedef signed long SLONG;
typedef float FLOAT;
typedef double DOUBLE;
typedef union
{
USHORT usData;
struct
{
#if defined(LITTLE_ENDIAN)
UCHAR ucLow;
UCHAR ucHigh;
#elif defined(BIG_ENDIAN)
UCHAR ucHigh;
UCHAR ucLow;
#else
#error
#endif
} stBytes;
} USHORT_UNION;
typedef union
{
ULONG ulData;
UCHAR aucBytes[4];
struct
{
// The least significant byte of the ULONG in this structure is
// referenced by ucByte0.
UCHAR ucByte0;
UCHAR ucByte1;
UCHAR ucByte2;
UCHAR ucByte3;
} stBytes;
} ULONG_UNION;
// The following macro computes offset (in bytes) of a member in a structure. This compiles to a constant.
#define STRUCT_OFFSET(MEMBER, STRUCT_POINTER) ( ((UCHAR *) &((STRUCT_POINTER) -> MEMBER)) - ((UCHAR *) (STRUCT_POINTER)) )
#endif // !defined(TYPES_H)