Debian Codegraph @

code/qcommon/q_platform.h

raw ◀ ▶
Source reconstructed at patch state 1 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 #if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
151
152 #include <endian.h>
153
154 #if defined(__linux__)
155 #define OS_STRING "linux"
156 #elif defined(__FreeBSD_kernel__)
157 #define OS_STRING "kFreeBSD"
158 #else
159 #define OS_STRING "GNU"
160 #endif
161
162 #define ID_INLINE inline
163 #define PATH_SEP '/'
164
165 #if defined __i386__
166 #define ARCH_STRING "i386"
167 #elif defined __x86_64__
168 #define ARCH_STRING "x86_64"
169 #elif defined __powerpc64__
170 #define ARCH_STRING "ppc64"
171 #elif defined __powerpc__
172 #define ARCH_STRING "ppc"
173 #elif defined __s390__
174 #define ARCH_STRING "s390"
175 #elif defined __s390x__
176 #define ARCH_STRING "s390x"
177 #elif defined __ia64__
178 #define ARCH_STRING "ia64"
179 #elif defined __alpha__
180 #define ARCH_STRING "alpha"
181 #elif defined __sparc__
182 #define ARCH_STRING "sparc"
183 #elif defined __arm__
184 #define ARCH_STRING "arm"
185 #elif defined __cris__
186 #define ARCH_STRING "cris"
187 #elif defined __hppa__
188 #define ARCH_STRING "hppa"
189 #elif defined __mips__
190 #define ARCH_STRING "mips"
191 #elif defined __sh__
192 #define ARCH_STRING "sh"
193 #endif
194
195 #if __FLOAT_WORD_ORDER == __BIG_ENDIAN
196 #define Q3_BIG_ENDIAN
197 #else
198 #define Q3_LITTLE_ENDIAN
199 #endif
200
201 #define DLL_EXT ".so"
202
203 #endif
204
205 //=================================================================== BSD ===
206
207 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
208
209 #include <sys/types.h>
210 #include <machine/endian.h>
211
212 #ifndef __BSD__
213 #define __BSD__
214 #endif
215
216 #if defined(__FreeBSD__)
217 #define OS_STRING "freebsd"
218 #elif defined(__OpenBSD__)
219 #define OS_STRING "openbsd"
220 #elif defined(__NetBSD__)
221 #define OS_STRING "netbsd"
222 #endif
223
224 #define ID_INLINE inline
225 #define PATH_SEP '/'
226
227 #ifdef __i386__
228 #define ARCH_STRING "i386"
229 #elif defined __axp__
230 #define ARCH_STRING "alpha"
231 #endif
232
233 #if BYTE_ORDER == BIG_ENDIAN
234 #define Q3_BIG_ENDIAN
235 #else
236 #define Q3_LITTLE_ENDIAN
237 #endif
238
239 #define DLL_EXT ".so"
240
241 #endif
242
243 //================================================================= SUNOS ===
244
245 #ifdef __sun
246
247 #include <stdint.h>
248 #include <sys/byteorder.h>
249
250 #define OS_STRING "solaris"
251 #define ID_INLINE inline
252 #define PATH_SEP '/'
253
254 #ifdef __i386__
255 #define ARCH_STRING "i386"
256 #elif defined __sparc
257 #define ARCH_STRING "sparc"
258 #endif
259
260 #if defined( _BIG_ENDIAN )
261 #define Q3_BIG_ENDIAN
262 #elif defined( _LITTLE_ENDIAN )
263 #define Q3_LITTLE_ENDIAN
264 #endif
265
266 #define DLL_EXT ".so"
267
268 #endif
269
270 //================================================================== IRIX ===
271
272 #ifdef __sgi
273
274 #define OS_STRING "irix"
275 #define ID_INLINE __inline
276 #define PATH_SEP '/'
277
278 #define ARCH_STRING "mips"
279
280 #define Q3_BIG_ENDIAN // SGI's MIPS are always big endian
281
282 #define DLL_EXT ".so"
283
284 #endif
285
286 //================================================================== Q3VM ===
287
288 #ifdef Q3_VM
289
290 #define OS_STRING "q3vm"
291 #define ID_INLINE
292 #define PATH_SEP '/'
293
294 #define ARCH_STRING "bytecode"
295
296 #define DLL_EXT ".qvm"
297
298 #endif
299
300 //===========================================================================
301
302 //catch missing defines in above blocks
303 #if !defined( OS_STRING )
304 #error "Operating system not supported"
305 #endif
306
307 #if !defined( ARCH_STRING )
308 #error "Architecture not supported"
309 #endif
310
311 #ifndef ID_INLINE
312 #error "ID_INLINE not defined"
313 #endif
314
315 #ifndef PATH_SEP
316 #error "PATH_SEP not defined"
317 #endif
318
319 #ifndef DLL_EXT
320 #error "DLL_EXT not defined"
321 #endif
322
323
324 //endianness
325 short ShortSwap (short l);
326 int LongSwap (int l);
327 float FloatSwap (const float *f);
328
329 #if defined( Q3_BIG_ENDIAN ) && defined( Q3_LITTLE_ENDIAN )
330 #error "Endianness defined as both big and little"
331 #elif defined( Q3_BIG_ENDIAN )
332
333 #define LittleShort(x) ShortSwap(x)
334 #define LittleLong(x) LongSwap(x)
335 #define LittleFloat(x) FloatSwap(&x)
336 #define BigShort
337 #define BigLong
338 #define BigFloat
339
340 #elif defined( Q3_LITTLE_ENDIAN )
341
342 #define LittleShort
343 #define LittleLong
344 #define LittleFloat
345 #define BigShort(x) ShortSwap(x)
346 #define BigLong(x) LongSwap(x)
347 #define BigFloat(x) FloatSwap(&x)
348
349 #elif defined( Q3_VM )
350
351 #define LittleShort
352 #define LittleLong
353 #define LittleFloat
354 #define BigShort
355 #define BigLong
356 #define BigFloat
357
358 #else
359 #error "Endianness not defined"
360 #endif
361
362
363 //platform string
364 #ifdef NDEBUG
365 #define PLATFORM_STRING OS_STRING "-" ARCH_STRING
366 #else
367 #define PLATFORM_STRING OS_STRING "-" ARCH_STRING "-debug"
368 #endif
369
370 #endif
371
372 #endif