Apply the new ground_level method.
[crawl.git] / crawl-ref / source / platform.h
blob4fdec579e878134971bf2af9fe5384edcd904c47
1 /*
2 * CrissCross
3 * A multi-purpose cross-platform library.
5 * A product of Uplink Laboratories.
7 * (c) 2006-2009 Steven Noonan.
8 * Licensed under the New BSD License.
14 * Preprocessor Definitions
15 * ------------------------
17 * TARGET_CPU_ARM
18 * ARM processor
19 * TARGET_CPU_ALPHA
20 * DEC Alpha processor
21 * TARGET_CPU_SPARC
22 * Sun Microsystems SPARC processor
23 * TARGET_CPU_X86
24 * Intel x86 processor
25 * TARGET_CPU_IA64
26 * Intel Itanic processor
27 * TARGET_CPU_X64
28 * Intel 64-bit processor
29 * TARGET_CPU_PPC
30 * IBM PowerPC processor
32 * TARGET_OS_WINDOWS
33 * Windows
34 * TARGET_OS_LINUX
35 * Linux
36 * TARGET_OS_MACOSX
37 * Mac OS X
38 * TARGET_OS_FREEBSD
39 * FreeBSD
40 * TARGET_OS_NETBSD
41 * NetBSD
42 * TARGET_OS_OPENBSD
43 * OpenBSD
44 * TARGET_OS_NDSFIRMWARE
45 * Nintendo DS firmware
47 * TARGET_COMPILER_GCC
48 * GNU C++ Compiler
49 * TARGET_COMPILER_MINGW
50 * GCC for MinGW
51 * TARGET_COMPILER_VC
52 * Visual C++
53 * TARGET_COMPILER_ICC
54 * Intel C++ Compiler
58 #ifndef __included_cc_platform_detect_h
59 #define __included_cc_platform_detect_h
61 #undef PROCESSOR_DETECTED
62 #undef COMPILER_DETECTED
63 #undef OS_DETECTED
65 /* ------------------- *
66 * PROCESSOR DETECTION *
67 * ------------------- */
69 /* Carbon defines this for us on Mac, apparently... */
70 #if defined (TARGET_CPU_PPC)
71 #define PROCESSOR_DETECTED
72 #endif
74 /* ARM */
75 #if !defined (PROCESSOR_DETECTED)
76 #if defined (__arm__)
77 #define PROCESSOR_DETECTED
78 #define TARGET_CPU_ARM
79 #endif
80 #endif
82 /* DEC Alpha */
83 #if !defined (PROCESSOR_DETECTED)
84 #if defined (__alpha) || defined (__alpha__)
85 #define PROCESSOR_DETECTED
86 #define TARGET_CPU_ALPHA
87 #endif
88 #endif
90 /* Sun SPARC */
91 #if !defined (PROCESSOR_DETECTED)
92 #if defined (__sparc) || defined (__sparc__)
93 #define PROCESSOR_DETECTED
94 #define TARGET_CPU_SPARC
95 #endif
96 #endif
98 /* MIPS */
99 #if !defined (PROCESSOR_DETECTED)
100 #if defined (__MIPSEL__)
101 #define PROCESSOR_DETECTED
102 #define TARGET_CPU_MIPS
103 #elif defined (__mips__)
104 #define PROCESSOR_DETECTED
105 #define TARGET_CPU_MIPS
106 #endif
107 #endif
109 /* PowerPC */
110 #if !defined (PROCESSOR_DETECTED)
111 #if defined (_ARCH_PPC) || defined (__ppc__) || defined (__ppc64__) || defined (__PPC) || defined (powerpc) || defined (__PPC__) || defined (__powerpc64__) || defined (__powerpc64)
112 #define PROCESSOR_DETECTED
113 #define TARGET_BIG_ENDIAN
114 #endif
115 #endif
117 /* x86_64 or AMD64 or x64 */
118 #if !defined (PROCESSOR_DETECTED)
119 #if defined (__x86_64__) || defined (__x86_64) || defined (__amd64) || defined (__amd64__) || defined (_AMD64_) || defined (_M_X64)
120 #define PROCESSOR_DETECTED
121 #define TARGET_CPU_X64
122 #define TARGET_CPU_X86_64
123 #endif
124 #endif
126 /* Intel x86 */
127 #if !defined (PROCESSOR_DETECTED)
128 #if defined (__i386__) || defined (__i386) || defined (i386) || defined (_X86_) || defined (_M_IX86)
129 #define PROCESSOR_DETECTED
130 #define TARGET_CPU_X86
131 #endif
132 #endif
134 /* IA64 */
135 #if !defined (PROCESSOR_DETECTED)
136 #if defined (__ia64__) || defined (_IA64) || defined (__ia64) || defined (_M_IA64)
137 #define PROCESSOR_DETECTED
138 #define TARGET_CPU_IA64
139 #define TARGET_LITTLE_ENDIAN
140 #endif
141 #endif
143 /* ------------------- *
144 * COMPILER DETECTION *
145 * ------------------- */
147 #if !defined (COMPILER_DETECTED)
148 #if defined (__GNUC__)
149 #define COMPILER_DETECTED
150 #define TARGET_COMPILER_GCC
151 #endif
152 #if defined (__CYGWIN__) || defined (__CYGWIN32__)
153 #define TARGET_COMPILER_CYGWIN
154 #endif
155 #if defined (__MINGW32__)
156 #define TARGET_COMPILER_MINGW
157 #endif
158 #if defined (__DJGPP__)
159 #define TARGET_COMPILER_DJGPP
160 #endif
161 #endif
163 #if !defined (COMPILER_DETECTED)
164 #if defined (__INTEL_COMPILER) || defined (__ICL)
165 #define COMPILER_DETECTED
166 #define TARGET_COMPILER_ICC
167 #endif
168 #endif
170 #if !defined (COMPILER_DETECTED)
171 #if defined (_MSC_VER)
172 #define COMPILER_DETECTED
173 #define TARGET_COMPILER_VC
174 #endif
175 #endif
177 #if !defined (COMPILER_DETECTED)
178 #if defined (__BORLANDC__)
179 /* Earlier Borland compilers break terribly */
180 #if __BORLANDC__ >= 0x0600
181 #define COMPILER_DETECTED
182 #define TARGET_COMPILER_BORLAND
183 #endif
184 #endif
185 #endif
187 /* ------------ *
188 * OS DETECTION *
189 * ------------ */
191 #if !defined (OS_DETECTED)
192 #if defined (TARGET_COMPILER_VC) || defined (_WIN32) || defined (_WIN64)
193 #define OS_DETECTED
194 #define TARGET_OS_WINDOWS
195 #endif
196 #endif
198 #if !defined (OS_DETECTED)
199 #if defined (__linux__) || defined (linux) || defined (__linux) || defined (__gnu_linux__) || defined (__CYGWIN__)
200 #define OS_DETECTED
201 #define TARGET_OS_LINUX
202 #endif
203 #endif
205 #if !defined (OS_DETECTED)
206 #if defined (TARGET_CPU_ARM)
207 #define OS_DETECTED
208 #define TARGET_OS_NDSFIRMWARE
209 #endif
210 #endif
212 #if !defined (OS_DETECTED)
213 #if defined (MSDOS) || defined (__DOS__) || defined (__DJGPP__)
214 #define OS_DETECTED
215 #define TARGET_OS_DOS
216 #endif
217 #endif
219 #if !defined (OS_DETECTED)
220 #if defined (__sun__)
221 #define OS_DETECTED
222 #define TARGET_OS_SOLARIS
223 #endif
224 #endif
226 #if !defined (OS_DETECTED)
227 #if defined (__FreeBSD__)
228 #define OS_DETECTED
229 #define TARGET_OS_FREEBSD
230 #endif
231 #endif
233 #if !defined (OS_DETECTED)
234 #if defined (__NetBSD__)
235 #define OS_DETECTED
236 #define TARGET_OS_NETBSD
237 #endif
238 #endif
240 #if !defined (OS_DETECTED)
241 #if defined (__OpenBSD__)
242 #define OS_DETECTED
243 #define TARGET_OS_OPENBSD
244 #endif
245 #endif
247 #if !defined (OS_DETECTED)
248 #if defined (__APPLE__)
249 #define OS_DETECTED
250 #define TARGET_OS_MACOSX
251 #endif
252 #endif
254 #if !defined (OS_DETECTED)
255 #if defined (__hurd__)
256 #define OS_DETECTED
257 #define TARGET_OS_HURD
258 #endif
259 #endif
261 //#if !defined (PROCESSOR_DETECTED)
262 //#error "Could not detect target CPU."
263 //#endif
265 //#if !defined (COMPILER_DETECTED)
266 //#error "Could not detect target compiler."
267 //#endif
269 #if !defined (OS_DETECTED)
270 #define TARGET_OS_UNKNOWN
271 //#error "Could not detect target OS."
272 #endif
274 /* ICC on Windows uses VC includes, etc */
275 #ifdef TARGET_OS_WINDOWS
276 #ifdef TARGET_COMPILER_ICC
277 #define TARGET_COMPILER_VC
278 #endif
279 #endif
281 #endif