/
types_uqm.h
155 lines (124 loc) · 3.51 KB
/
types_uqm.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Data types used in the UQM port
* Draft 3
* Compiled from various sources
*/
#ifndef _TYPES_H
#define _TYPES_H
#ifdef _MSC_VER
# if (_MSC_VER >= 1300)
# include <stddef.h>
# else
typedef int intptr_t;
typedef unsigned int uintptr_t;
# endif
# ifdef _WIN64
# define PRIxPTR "lx"
# else
# define PRIxPTR "x"
# endif
#else
# include <inttypes.h>
#endif
#if defined(__arch64__) || defined(__alpha) || defined(__x86_64) \
|| defined(_M_IA64) || defined(_M_AMD64)
/* 64-bit platforms */
# define UQM_INT16 short
# define UQM_INT32 int
# define UQM_INT64 long
#elif defined(__MACOS__)
# define UQM_INT16 short
# define UQM_INT32 long
/* Add your OS support here */
#else
/* all other sane 32bit: WIN32, __MACOSX__, __BEOS__, __EMX__ */
# define UQM_INT16 short
# define UQM_INT32 int
#endif
/* Figure out how to support 64-bit datatypes */
#if !defined(UQM_INT64) && !defined(__STRICT_ANSI__)
# if defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C)
# define UQM_INT64 long long
# elif defined(_MSC_VER) || defined(__BORLANDC__)
# define UQM_INT64 __int64
# endif
#endif /* !__STRICT_ANSI__ */
/* The 64-bit type isn't available on EPOC/Symbian OS */
#ifdef __SYMBIAN32__
# undef UQM_INT64
#endif
typedef enum
{
false = 0,
true
} bool;
/* If it isn't char, what is it ?!*/
typedef unsigned char uint8;
typedef signed char sint8;
typedef unsigned UQM_INT16 uint16;
typedef signed UQM_INT16 sint16;
typedef unsigned UQM_INT32 uint32;
typedef signed UQM_INT32 sint32;
#if defined(UQM_INT64)
typedef unsigned UQM_INT64 uint64;
typedef signed UQM_INT64 sint64;
#undef UQM_INT64
#else /* dont have UQM_INT64 */
typedef struct
{
uint32 hi;
uint32 lo;
} uint64;
typedef struct
{
sint32 hi;
uint32 lo;
} sint64;
#endif /* UQM_INT64 */
#undef UQM_INT16
#undef UQM_INT32
/* Make sure the types really have the right sizes
* Adapted from SDL
* This will generate "negative subscript or subscript is too large"
* error during compile, if the actual size of a type is wrong
*/
#define UQM_COMPILE_TIME_ASSERT(name, x) \
typedef int UQM_dummy_##name [(x) * 2 - 1]
UQM_COMPILE_TIME_ASSERT(uint8, sizeof(uint8) == 1);
UQM_COMPILE_TIME_ASSERT(uint16, sizeof(uint16) == 2);
UQM_COMPILE_TIME_ASSERT(uint32, sizeof(uint32) == 4);
UQM_COMPILE_TIME_ASSERT(uint64, sizeof(uint64) == 8);
#undef UQM_COMPILE_TIME_ASSERT
#undef SINT8_MIN
#undef SINT8_MAX
#undef SINT16_MIN
#undef SINT16_MAX
#undef SINT32_MIN
#undef SINT32_MAX
#undef UINT8_MAX
#undef UINT16_MAX
#undef UINT32_MAX
#define SINT8_MIN (-128)
#define SINT8_MAX 127
#define SINT16_MIN (-32767-1)
#define SINT16_MAX 32767
#define SINT32_MIN (-2147483647-1)
#define SINT32_MAX 2147483647
#define UINT8_MAX 0xff /* 255U */
#define UINT16_MAX 0xffff /* 65535U */
#define UINT32_MAX 0xffffffff /* 4294967295U */
#endif /* _TYPES_H */