source: Daodan/src/beaengine/basic_types.h@ 986

Last change on this file since 986 was 984, checked in by alloc, 11 years ago

Daodan: TV code

File size: 8.2 KB
Line 
1/**
2 * @file basic_types.h
3 * @author <igor.gutnik@gmail.com>
4 * @date Thu Dec 24 19:31:22 2009
5 *
6 * @brief Definitions of fixed-size integer types for various platforms
7 *
8 * This file is part of BeaEngine.
9 *
10 * BeaEngine is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * BeaEngine is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with BeaEngine. If not, see <http://www.gnu.org/licenses/>. */
22
23#ifndef __BEA_BASIC_TYPES_HPP__
24#define __BEA_BASIC_TYPES_HPP__
25
26#include <stddef.h>
27
28#if defined(__GNUC__) || defined (__INTEL_COMPILER) || defined(__LCC__) || defined(__POCC__)
29#include <stdint.h>
30#endif
31
32#if defined(_MSC_VER) && !defined(__BORLANDC__)
33 /*
34 * Windows/Visual C++
35 */
36 typedef signed char Int8;
37 typedef unsigned char UInt8;
38 typedef signed short Int16;
39 typedef unsigned short UInt16;
40 typedef signed int Int32;
41 typedef unsigned int UInt32;
42 typedef signed __int64 Int64;
43 typedef unsigned __int64 UInt64;
44 #if defined(_WIN64)
45 #define BEA_PTR_IS_64_BIT 1
46 typedef signed __int64 IntPtr;
47 typedef unsigned __int64 UIntPtr;
48 #else
49 typedef signed long IntPtr;
50 typedef size_t UIntPtr;
51 #endif
52 #define BEA_HAVE_INT64 1
53#elif defined(__POCC__)
54 /*
55 * PellesC
56 */
57 typedef signed char Int8;
58 typedef unsigned char UInt8;
59 typedef signed short Int16;
60 typedef unsigned short UInt16;
61 typedef signed int Int32;
62 typedef unsigned int UInt32;
63 typedef signed long long Int64;
64 typedef unsigned long long UInt64;
65 #if defined(_WIN64)
66 #define BEA_PTR_IS_64_BIT 1
67 typedef signed long long IntPtr;
68 typedef unsigned long long UIntPtr;
69 #else
70 typedef signed long IntPtr;
71 typedef size_t UIntPtr;
72 #endif
73 #define BEA_HAVE_INT64 1
74#elif defined(__GNUC__) || defined(__LCC__)
75 /*
76 * Unix/GCC
77 */
78 typedef signed char Int8;
79 typedef unsigned char UInt8;
80 typedef signed short Int16;
81 typedef unsigned short UInt16;
82 typedef signed int Int32;
83 typedef unsigned int UInt32;
84 typedef intptr_t IntPtr;
85 typedef uintptr_t UIntPtr;
86 #if defined(__LP64__)
87 #define BEA_PTR_IS_64_BIT 1
88 #define BEA_LONG_IS_64_BIT 1
89 typedef signed long Int64;
90 typedef unsigned long UInt64;
91 #else
92 #if defined (__INTEL_COMPILER) || defined (__ICC) || defined (_ICC)
93 typedef __int64 Int64;
94 typedef unsigned __int64 UInt64;
95 #else
96 typedef signed long long Int64;
97 typedef unsigned long long UInt64;
98 #endif
99 #endif
100 #define BEA_HAVE_INT64 1
101#elif defined(__DECCXX)
102 /*
103 * Compaq C++
104 */
105 typedef signed char Int8;
106 typedef unsigned char UInt8;
107 typedef signed short Int16;
108 typedef unsigned short UInt16;
109 typedef signed int Int32;
110 typedef unsigned int UInt32;
111 typedef signed __int64 Int64;
112 typedef unsigned __int64 UInt64;
113 #if defined(__VMS)
114 #if defined(__32BITS)
115 typedef signed long IntPtr;
116 typedef unsigned long UIntPtr;
117 #else
118 typedef Int64 IntPtr;
119 typedef UInt64 UIntPtr;
120 #define BEA_PTR_IS_64_BIT 1
121 #endif
122 #else
123 typedef signed long IntPtr;
124 typedef unsigned long UIntPtr;
125 #define BEA_PTR_IS_64_BIT 1
126 #define BEA_LONG_IS_64_BIT 1
127 #endif
128 #define BEA_HAVE_INT64 1
129#elif defined(__HP_aCC)
130 /*
131 * HP Ansi C++
132 */
133 typedef signed char Int8;
134 typedef unsigned char UInt8;
135 typedef signed short Int16;
136 typedef unsigned short UInt16;
137 typedef signed int Int32;
138 typedef unsigned int UInt32;
139 typedef signed long IntPtr;
140 typedef unsigned long UIntPtr;
141 #if defined(__LP64__)
142 #define BEA_PTR_IS_64_BIT 1
143 #define BEA_LONG_IS_64_BIT 1
144 typedef signed long Int64;
145 typedef unsigned long UInt64;
146 #else
147 typedef signed long long Int64;
148 typedef unsigned long long UInt64;
149 #endif
150 #define BEA_HAVE_INT64 1
151#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
152 /*
153 * SUN Forte C++
154 */
155 typedef signed char Int8;
156 typedef unsigned char UInt8;
157 typedef signed short Int16;
158 typedef unsigned short UInt16;
159 typedef signed int Int32;
160 typedef unsigned int UInt32;
161 typedef signed long IntPtr;
162 typedef unsigned long UIntPtr;
163 #if defined(__sparcv9)
164 #define BEA_PTR_IS_64_BIT 1
165 #define BEA_LONG_IS_64_BIT 1
166 typedef signed long Int64;
167 typedef unsigned long UInt64;
168 #else
169 typedef signed long long Int64;
170 typedef unsigned long long UInt64;
171 #endif
172 #define BEA_HAVE_INT64 1
173#elif defined(__IBMCPP__)
174 /*
175 * IBM XL C++
176 */
177 typedef signed char Int8;
178 typedef unsigned char UInt8;
179 typedef signed short Int16;
180 typedef unsigned short UInt16;
181 typedef signed int Int32;
182 typedef unsigned int UInt32;
183 typedef signed long IntPtr;
184 typedef unsigned long UIntPtr;
185 #if defined(__64BIT__)
186 #define BEA_PTR_IS_64_BIT 1
187 #define BEA_LONG_IS_64_BIT 1
188 typedef signed long Int64;
189 typedef unsigned long UInt64;
190 #else
191 typedef signed long long Int64;
192 typedef unsigned long long UInt64;
193 #endif
194 #define BEA_HAVE_INT64 1
195#elif defined(__BORLANDC__)
196 /*
197 * Borland C/C++
198 */
199 typedef signed char Int8;
200 typedef unsigned char UInt8;
201 typedef signed short Int16;
202 typedef unsigned short UInt16;
203 typedef signed int Int32;
204 typedef unsigned int UInt32;
205 typedef unsigned __int64 Int64;
206 typedef signed __int64 UInt64;
207 typedef signed long IntPtr;
208 typedef unsigned long UIntPtr;
209 #define BEA_HAVE_INT64 1
210#elif defined(__WATCOMC__)
211 /*
212 * Watcom C/C++
213 */
214 typedef signed char Int8;
215 typedef unsigned char UInt8;
216 typedef signed short Int16;
217 typedef unsigned short UInt16;
218 typedef signed int Int32;
219 typedef unsigned int UInt32;
220 typedef unsigned __int64 Int64;
221 typedef signed __int64 UInt64;
222 #define BEA_HAVE_INT64 1
223 typedef size_t UIntPtr;
224#elif defined(__sgi)
225 /*
226 * MIPSpro C++
227 */
228 typedef signed char Int8;
229 typedef unsigned char UInt8;
230 typedef signed short Int16;
231 typedef unsigned short UInt16;
232 typedef signed int Int32;
233 typedef unsigned int UInt32;
234 typedef signed long IntPtr;
235 typedef unsigned long UIntPtr;
236 #if _MIPS_SZLONG == 64
237 #define BEA_PTR_IS_64_BIT 1
238 #define BEA_LONG_IS_64_BIT 1
239 typedef signed long Int64;
240 typedef unsigned long UInt64;
241 #else
242 typedef signed long long Int64;
243 typedef unsigned long long UInt64;
244 #endif
245 #define BEA_HAVE_INT64 1
246#endif
247
248#if defined(_MSC_VER) || defined(__BORLANDC__)
249 #define W64LIT(x) x##ui64
250#else
251 #define W64LIT(x) x##ULL
252#endif
253
254
255#ifndef C_STATIC_ASSERT
256#define C_STATIC_ASSERT(tag_name, x) \
257 typedef int cache_static_assert_ ## tag_name[(x) * 2-1]
258#endif
259
260C_STATIC_ASSERT(sizeof_Int8 , (sizeof(Int8) == 1));
261C_STATIC_ASSERT(sizeof_UInt8, (sizeof(UInt8) == 1));
262
263C_STATIC_ASSERT(sizeof_Int16 , (sizeof(Int16) == 2));
264C_STATIC_ASSERT(sizeof_UInt16, (sizeof(UInt16) == 2));
265
266C_STATIC_ASSERT(sizeof_Int32 , (sizeof(Int32) == 4));
267C_STATIC_ASSERT(sizeof_UInt32, (sizeof(UInt32) == 4));
268
269C_STATIC_ASSERT(sizeof_Int64 , (sizeof(Int64) == 8));
270C_STATIC_ASSERT(sizeof_UInt64, (sizeof(UInt64) == 8));
271
272#endif
Note: See TracBrowser for help on using the repository browser.