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 * ------------------------
22 * Sun Microsystems SPARC processor
26 * Intel Itanic processor
28 * Intel 64-bit processor
30 * IBM PowerPC processor
44 * TARGET_OS_NDSFIRMWARE
45 * Nintendo DS firmware
49 * TARGET_COMPILER_MINGW
58 #ifndef __included_cc_platform_detect_h
59 #define __included_cc_platform_detect_h
61 #undef PROCESSOR_DETECTED
62 #undef COMPILER_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
75 #if !defined (PROCESSOR_DETECTED)
77 #define PROCESSOR_DETECTED
78 #define TARGET_CPU_ARM
83 #if !defined (PROCESSOR_DETECTED)
84 #if defined (__alpha) || defined (__alpha__)
85 #define PROCESSOR_DETECTED
86 #define TARGET_CPU_ALPHA
91 #if !defined (PROCESSOR_DETECTED)
92 #if defined (__sparc) || defined (__sparc__)
93 #define PROCESSOR_DETECTED
94 #define TARGET_CPU_SPARC
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
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
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
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
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
143 /* ------------------- *
144 * COMPILER DETECTION *
145 * ------------------- */
147 #if !defined (COMPILER_DETECTED)
148 #if defined (__GNUC__)
149 #define COMPILER_DETECTED
150 #define TARGET_COMPILER_GCC
152 #if defined (__CYGWIN__) || defined (__CYGWIN32__)
153 #define TARGET_COMPILER_CYGWIN
155 #if defined (__MINGW32__)
156 #define TARGET_COMPILER_MINGW
158 #if defined (__DJGPP__)
159 #define TARGET_COMPILER_DJGPP
163 #if !defined (COMPILER_DETECTED)
164 #if defined (__INTEL_COMPILER) || defined (__ICL)
165 #define COMPILER_DETECTED
166 #define TARGET_COMPILER_ICC
170 #if !defined (COMPILER_DETECTED)
171 #if defined (_MSC_VER)
172 #define COMPILER_DETECTED
173 #define TARGET_COMPILER_VC
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
191 #if !defined (OS_DETECTED)
192 #if defined (TARGET_COMPILER_VC) || defined (_WIN32) || defined (_WIN64)
194 #define TARGET_OS_WINDOWS
198 #if !defined (OS_DETECTED)
199 #if defined (__linux__) || defined (linux) || defined (__linux) || defined (__gnu_linux__) || defined (__CYGWIN__)
201 #define TARGET_OS_LINUX
205 #if !defined (OS_DETECTED)
206 #if defined (TARGET_CPU_ARM)
208 #define TARGET_OS_NDSFIRMWARE
212 #if !defined (OS_DETECTED)
213 #if defined (MSDOS) || defined (__DOS__) || defined (__DJGPP__)
215 #define TARGET_OS_DOS
219 #if !defined (OS_DETECTED)
220 #if defined (__sun__)
222 #define TARGET_OS_SOLARIS
226 #if !defined (OS_DETECTED)
227 #if defined (__FreeBSD__)
229 #define TARGET_OS_FREEBSD
233 #if !defined (OS_DETECTED)
234 #if defined (__NetBSD__)
236 #define TARGET_OS_NETBSD
240 #if !defined (OS_DETECTED)
241 #if defined (__OpenBSD__)
243 #define TARGET_OS_OPENBSD
247 #if !defined (OS_DETECTED)
248 #if defined (__APPLE__)
250 #define TARGET_OS_MACOSX
254 #if !defined (OS_DETECTED)
255 #if defined (__hurd__)
257 #define TARGET_OS_HURD
261 //#if !defined (PROCESSOR_DETECTED)
262 //#error "Could not detect target CPU."
265 //#if !defined (COMPILER_DETECTED)
266 //#error "Could not detect target compiler."
269 #if !defined (OS_DETECTED)
270 #define TARGET_OS_UNKNOWN
271 //#error "Could not detect target OS."
274 /* ICC on Windows uses VC includes, etc */
275 #ifdef TARGET_OS_WINDOWS
276 #ifdef TARGET_COMPILER_ICC
277 #define TARGET_COMPILER_VC