Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
opcodetypes.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 1998-2004 by Jorrit Tyberghein
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public
15  License along with this library; if not, write to the Free
16  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 
19 #ifndef __CS_CSTYPES_H__
20 #define __CS_CSTYPES_H__
21 
22 // config.h is the VS ./configure determined header.
23 #include "config.h"
24 #include <float.h>
25 #include <wchar.h>
26 #if defined(_WIN32) && !defined(__CYGWIN__) // && defined(_MSC_VER)
27 // Hack
28 #define CS_COMPILER_MSVC 1
29 #ifdef _WIN64
30 # define CS_PROCESSOR_SIZE 64 /* Only used if intptr_t is not found. */
31 #else
32 # define CS_PROCESSOR_SIZE 32 /* Only used if intptr_t is not found. (cough VC6 cough) */
33 #endif
34 #define CS_HAVE_INTPTR_T 1
35 
36 #else /* GCC or other platform */
37 
38 #define CS_COMPILER_GCC 1
39 #define CS_PROCESSOR_SIZE 64 /* Upper limit on pointer size, only used it intptr_t is not found. */
40 #define CS_HAVE_INTPTR_T 1
41 
42 #endif
43 // End Hack
44 
45 
46 #if defined(HAVE_STDINT_H)
47 #ifndef __STDC_CONSTANT_MACROS
48 #define __STDC_CONSTANT_MACROS
49 #endif
50 #ifndef __STDC_LIMIT_MACROS
51 #define __STDC_LIMIT_MACROS
52 #endif
53 #include <stdint.h>
54 #endif
55 
56 #if defined(HAVE_INTTYPES_H)
57 #ifndef __STDC_FORMAT_MACROS
58 #define __STDC_FORMAT_MACROS
59 #endif
60 #include <inttypes.h>
61 #endif
62 
71 #if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H)
72 typedef unsigned char uint8;
75 typedef char int8;
77 typedef unsigned short uint16;
79 typedef short int16;
81 typedef unsigned int uint32;
83 typedef int int32;
84 #if defined(CS_COMPILER_GCC)
85 #ifndef __STRICT_ANSI__
86 typedef unsigned long long uint64;
89 typedef long long int64;
90 #endif
91 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC)
92 typedef unsigned __int64 uint64;
95 typedef __int64 int64;
96 #else
97 #error Do not know how to declare 64-bit integers
98 #endif // CS_COMPILER_GCC
99 
100 #else // CS_HAVE_STDINT_H || CS_HAVE_INTTYPES_H
101 
102 typedef uint8_t uint8;
103 typedef int8_t int8;
104 typedef uint16_t uint16;
105 typedef int16_t int16;
106 typedef uint32_t uint32;
107 typedef int32_t int32;
108 typedef uint64_t uint64;
109 typedef int64_t int64;
110 #endif
111 
112 #ifdef CS_HAVE_INT64_C
113 
119 #define CONST_INT64(x) INT64_C(x)
120 
126 #define CONST_UINT64(x) UINT64_C(x)
127 
128 #else // CS_HAVE_INT64_C
129 
130 #if defined(CS_COMPILER_GCC)
131 #define CONST_INT64(x) x ## LL
132 #define CONST_UINT64(x) x ## ULL
133 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC)
134 #define CONST_INT64(x) x##i64
135 #define CONST_UINT64(x) x##ui64
136 #else
137 #error Do not know how to contruct 64-bit integer constants
138 #endif // CS_COMPILER_GCC
139 
140 #endif // CS_HAVE_INT64_C
141 
147 // Provide intptr_t and uintptr_t. If the configure script determined that
148 // these types exist in the standard headers, then just employ those types.
149 // For MSVC, where the configure script is not used, check <stddef.h>, which is
150 // one of several headers which may provide these types. We can tell if
151 // <stddef.h> provided the types by checking if _INTPTR_T_DEFINED has been
152 // #defined; newer versions of MSVC will provide them; older ones will not. If
153 // all else fails, then we fake up these types on our own.
154 #include <stddef.h>
155 #if !defined(CS_HAVE_INTPTR_T) && !defined(_INTPTR_T_DEFINED)
156 
157 #if CS_PROCESSOR_SIZE == 64
158 typedef int64 intptr_t;
159 typedef uint64 uintptr_t;
160 typedef int64 ptrdiff_t;
161 #else
162 typedef int intptr_t;
165 typedef unsigned int uintptr_t;
167 typedef int ptrdiff_t;
168 #endif
169 
170 #define _INTPTR_T_DEFINED
171 #define _UINTPTR_T_DEFINED
172 #define _PTRDIFF_T_DEFINED
173 #endif
174 
175 #if !defined(CS_HAVE_INTMAX_T)
176 typedef int64 intmax_t;
180 #endif
181 
182 
183 // Provide wchar_t and wint_t. If the configure script determined that these
184 // types exist in the standard headers, then just employ those types. For
185 // MSVC, where the configure script is not used, check <stddef.h>, <wchar.h>,
186 // and <wctype.h>, which are three of several headers which may provide these
187 // types. We can tell if these headers provided the types by checking if
188 // _WCHAR_T_DEFINED and _WCTYPE_T_DEFINED have been #defined; newer versions of
189 // MSVC will provide them; older ones will not. If all else fails, then we
190 // fake up these types on our own. glibc also #defines _WINT_T when wint_t is
191 // available, so we double-check that, as well. Many modern compilaers also
192 // allow us to check for wint_t directly, so we also do that (seems to be
193 // necessary in FreeBSD). FreeBSD does define _WINT_T_DECLARED, so we check fo tha
194 // too.
195 #include <stddef.h>
196 #if defined(HAVE_WCTYPE_H)
197 #include <wctype.h>
198 #endif
199 #if !((defined(CS_HAVE_WINT_T) && defined(_WCTYPE_T_DEFINED)) || defined(_WINT_T) || defined(_WINT_T_DECLARED))
200 #ifndef wint_t
201 #if _MSC_VER >= 1300
202  typedef unsigned short wint_t;
203 #else
204  typedef wchar_t wint_t;
205 #endif
206 #endif
207 #define _WCTYPE_T_DEFINED
208 #define _WINT_T
209 #define _WINT_T_DECLARED
210 #endif
211 
212 
213 #if defined(CS_COMPILER_GCC)
214 #ifndef __STRICT_ANSI__
215 
218 typedef long long longlong;
222 typedef unsigned long long ulonglong;
223 #else
224 // @@@ Correct?
225 typedef int64 longlong;
226 typedef uint64 ulonglong;
227 #endif
228 #elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC)
229 typedef int64 longlong;
230 typedef uint64 ulonglong;
231 #else
232 #ifdef HAVE_STDINT_H
233 typedef int_least64_t longlong;
234 typedef uint_least64_t ulonglong;
235 #else
236 #error Do not know how to declare (u)longlong types
237 #endif
238 #endif
239 
246 typedef unsigned int csTicks;
247 
249 typedef unsigned int uint;
254 #endif // __CS_CSTYPES_H__