Debian Codegraph @

code/qcommon/q_platform.h

raw ◀ ▶
Source reconstructed at patch state 0 of 3 — not the installed (fully patched) source.
3 Debian patches touch this file
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22
23 #ifndef __Q_PLATFORM_H
24 #define __Q_PLATFORM_H
25
26 // this is for determining if we have an asm version of a C function
27 #ifdef Q3_VM
28
29 #define id386 0
30 #define idppc 0
31 #define idppc_altivec 0
32
33 #else
34
35 #if (defined _M_IX86 || defined __i386__) && !defined(C_ONLY)
36 #define id386 1
37 #else
38 #define id386 0
39 #endif
40
41 #if (defined(powerc) || defined(powerpc) || defined(ppc) || \
42 defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
43 #define idppc 1
44 #if defined(__VEC__)
45 #define idppc_altivec 1
46 #ifdef MACOS_X // Apple's GCC does this differently than the FSF.
47 #define VECCONST_UINT8(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
48 (vector unsigned char) (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)
49 #else
50 #define VECCONST_UINT8(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
51 (vector unsigned char) {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}
52 #endif
53 #else
54 #define idppc_altivec 0
55 #endif
56 #else
57 #define idppc 0
58 #define idppc_altivec 0
59 #endif
60
61 #endif
62
63 #ifndef __ASM_I386__ // don't include the C bits if included from qasm.h
64
65 // for windows fastcall option
66 #define QDECL
67
68 //================================================================= WIN32 ===
69
70 #ifdef __MINGW32__
71
72 #undef QDECL
73 #define QDECL __cdecl
74
75 #if defined( _MSC_VER )
76 #define OS_STRING "win_msvc"
77 #elif defined __MINGW32__
78 #define OS_STRING "win_mingw"
79 #endif
80
81 #define ID_INLINE __inline
82 #define PATH_SEP '\\'
83
84 #if defined( _M_IX86 ) || defined( __i386__ )
85 #define ARCH_STRING "x86"
86 #elif defined _M_ALPHA
87 #define ARCH_STRING "AXP"
88 #endif
89
90 #define Q3_LITTLE_ENDIAN
91
92 #define DLL_EXT ".dll"
93
94 #endif
95
96 //KK-OAX, This is a little hack to be able to build dll's for debugging under Visual Studio
97 //Simple copy/paste/rename of the #ifdef __MINGW32__
98 #ifdef VSTUDIO
99
100 #undef QDECL
101 #define QDECL __cdecl
102
103 #if defined( _MSC_VER )
104 #define OS_STRING "win_msvc"
105 #elif defined __MINGW32__
106 #define OS_STRING "win_mingw"
107 #endif
108
109 #define ID_INLINE __inline
110 #define PATH_SEP '\\'
111
112 #if defined( _M_IX86 ) || defined( __i386__ )
113 #define ARCH_STRING "x86"
114 #elif defined _M_ALPHA
115 #define ARCH_STRING "AXP"
116 #endif
117
118 #define Q3_LITTLE_ENDIAN
119
120 #define DLL_EXT ".dll"
121
122 #endif
123 //============================================================== MAC OS X ===
124
125 #if defined(MACOS_X) || defined(__APPLE_CC__)
126
127 // make sure this is defined, just for sanity's sake...
128 #ifndef MACOS_X
129 #define MACOS_X
130 #endif
131
132 #define OS_STRING "macosx"
133 #define ID_INLINE inline
134 #define PATH_SEP '/'
135
136 #ifdef __ppc__
137 #define ARCH_STRING "ppc"
138 #define Q3_BIG_ENDIAN
139 #elif defined __i386__
140 #define ARCH_STRING "i386"
141 #define Q3_LITTLE_ENDIAN
142 #endif
143
144 #define DLL_EXT ".dylib"
145
146 #endif
147
148 //================================================================= LINUX ===
149
150 #ifdef __linux__
151
152 #include <endian.h>
153
154 #define OS_STRING "linux"
155 #define ID_INLINE inline
156 #define PATH_SEP '/'
157
158 #if defined __i386__
159 #define ARCH_STRING "i386"
160 #elif defined __x86_64__
161 #define ARCH_STRING "x86_64"
162 #elif defined __powerpc64__
163 #define ARCH_STRING "ppc64"
164 #elif defined __powerpc__
165 #define ARCH_STRING "ppc"
166 #elif defined __s390__
167 #define ARCH_STRING "s390"
168 #elif defined __s390x__
169 #define ARCH_STRING "s390x"
170 #elif defined __ia64__
171 #define ARCH_STRING "ia64"
172 #elif defined __alpha__
173 #define ARCH_STRING "alpha"
174 #elif defined __sparc__
175 #define ARCH_STRING "sparc"
176 #elif defined __arm__
177 #define ARCH_STRING "arm"
178 #elif defined __cris__
179 #define ARCH_STRING "cris"
180 #elif defined __hppa__
181 #define ARCH_STRING "hppa"
182 #elif defined __mips__
183 #define ARCH_STRING "mips"
184 #elif defined __sh__
185 #define ARCH_STRING "sh"
186 #endif
187
188 #if __FLOAT_WORD_ORDER == __BIG_ENDIAN
189 #define Q3_BIG_ENDIAN
190 #else
191 #define Q3_LITTLE_ENDIAN
192 #endif
193
194 #define DLL_EXT ".so"
195
196 #endif
197
198 //=================================================================== BSD ===
199
200 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
201
202 #include <sys/types.h>
203 #include <machine/endian.h>
204
205 #ifndef __BSD__
206 #define __BSD__
207 #endif
208
209 #if defined(__FreeBSD__)
210 #define OS_STRING "freebsd"
211 #elif defined(__OpenBSD__)
212 #define OS_STRING "openbsd"
213 #elif defined(__NetBSD__)
214 #define OS_STRING "netbsd"
215 #endif
216
217 #define ID_INLINE inline
218 #define PATH_SEP '/'
219
220 #ifdef __i386__
221 #define ARCH_STRING "i386"
222 #elif defined __axp__
223 #define ARCH_STRING "alpha"
224 #endif
225
226 #if BYTE_ORDER == BIG_ENDIAN
227 #define Q3_BIG_ENDIAN
228 #else
229 #define Q3_LITTLE_ENDIAN
230 #endif
231
232 #define DLL_EXT ".so"
233
234 #endif
235
236 //================================================================= SUNOS ===
237
238 #ifdef __sun
239
240 #include <stdint.h>
241 #include <sys/byteorder.h>
242
243 #define OS_STRING "solaris"
244 #define ID_INLINE inline
245 #define PATH_SEP '/'
246
247 #ifdef __i386__
248 #define ARCH_STRING "i386"
249 #elif defined __sparc
250 #define ARCH_STRING "sparc"
251 #endif
252
253 #if defined( _BIG_ENDIAN )
254 #define Q3_BIG_ENDIAN
255 #elif defined( _LITTLE_ENDIAN )
256 #define Q3_LITTLE_ENDIAN
257 #endif
258
259 #define DLL_EXT ".so"
260
261 #endif
262
263 //================================================================== IRIX ===
264
265 #ifdef __sgi
266
267 #define OS_STRING "irix"
268 #define ID_INLINE __inline
269 #define PATH_SEP '/'
270
271 #define ARCH_STRING "mips"
272
273 #define Q3_BIG_ENDIAN // SGI's MIPS are always big endian
274
275 #define DLL_EXT ".so"
276
277 #endif
278
279 //================================================================== Q3VM ===
280
281 #ifdef Q3_VM
282
283 #define OS_STRING "q3vm"
284 #define ID_INLINE
285 #define PATH_SEP '/'
286
287 #define ARCH_STRING "bytecode"
288
289 #define DLL_EXT ".qvm"
290
291 #endif
292
293 //===========================================================================
294
295 //catch missing defines in above blocks
296 #if !defined( OS_STRING )
297 #error "Operating system not supported"
298 #endif
299
300 #if !defined( ARCH_STRING )
301 #error "Architecture not supported"
302 #endif
303
304 #ifndef ID_INLINE
305 #error "ID_INLINE not defined"
306 #endif
307
308 #ifndef PATH_SEP
309 #error "PATH_SEP not defined"
310 #endif
311
312 #ifndef DLL_EXT
313 #error "DLL_EXT not defined"
314 #endif
315
316
317 //endianness
318 short ShortSwap (short l);
319 int LongSwap (int l);
320 float FloatSwap (const float *f);
321
322 #if defined( Q3_BIG_ENDIAN ) && defined( Q3_LITTLE_ENDIAN )
323 #error "Endianness defined as both big and little"
324 #elif defined( Q3_BIG_ENDIAN )
325
326 #define LittleShort(x) ShortSwap(x)
327 #define LittleLong(x) LongSwap(x)
328 #define LittleFloat(x) FloatSwap(&x)
329 #define BigShort
330 #define BigLong
331 #define BigFloat
332
333 #elif defined( Q3_LITTLE_ENDIAN )
334
335 #define LittleShort
336 #define LittleLong
337 #define LittleFloat
338 #define BigShort(x) ShortSwap(x)
339 #define BigLong(x) LongSwap(x)
340 #define BigFloat(x) FloatSwap(&x)
341
342 #elif defined( Q3_VM )
343
344 #define LittleShort
345 #define LittleLong
346 #define LittleFloat
347 #define BigShort
348 #define BigLong
349 #define BigFloat
350
351 #else
352 #error "Endianness not defined"
353 #endif
354
355
356 //platform string
357 #ifdef NDEBUG
358 #define PLATFORM_STRING OS_STRING "-" ARCH_STRING
359 #else
360 #define PLATFORM_STRING OS_STRING "-" ARCH_STRING "-debug"
361 #endif
362
363 #endif
364
365 #endif