1 /* 2 * Copyright (c) 2000-2014 by Apple Inc.. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24 /* 25 File: TargetConditionals.h 26 27 Contains: Autoconfiguration of TARGET_ conditionals for Mac OS X and iPhone 28 29 Note: TargetConditionals.h in 3.4 Universal Interfaces works 30 with all compilers. This header only recognizes compilers 31 known to run on Mac OS X. 32 33 */ 34 35 #ifndef __TARGETCONDITIONALS__ 36 #define __TARGETCONDITIONALS__ 37 /**************************************************************************************************** 38 39 TARGET_CPU_* 40 These conditionals specify which microprocessor instruction set is being 41 generated. At most one of these is true, the rest are false. 42 43 TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode 44 TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode 45 TARGET_CPU_68K - Compiler is generating 680x0 instructions 46 TARGET_CPU_X86 - Compiler is generating x86 instructions 47 TARGET_CPU_ARM - Compiler is generating ARM instructions 48 TARGET_CPU_MIPS - Compiler is generating MIPS instructions 49 TARGET_CPU_SPARC - Compiler is generating Sparc instructions 50 TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions 51 52 53 TARGET_OS_* 54 These conditionals specify in which Operating System the generated code will 55 run. The MAC/WIN32/UNIX conditionals are mutually exclusive. The EMBEDDED/IPHONE 56 conditionals are variants of TARGET_OS_MAC. 57 58 TARGET_OS_MAC - Generate code will run under Mac OS 59 TARGET_OS_WIN32 - Generate code will run under 32-bit Windows 60 TARGET_OS_UNIX - Generate code will run under some non Mac OS X unix 61 TARGET_OS_EMBEDDED - Generate code will run under an embedded OS variant 62 of TARGET_OS_MAC 63 TARGET_OS_IPHONE - Generate code will run under iPhone OS which 64 is a variant of TARGET_OS_MAC. 65 66 TARGET_RT_* 67 These conditionals specify in which runtime the generated code will 68 run. This is needed when the OS and CPU support more than one runtime 69 (e.g. Mac OS X supports CFM and mach-o). 70 71 TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers 72 TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers 73 TARGET_RT_64_BIT - Generated code uses 64-bit pointers 74 TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used 75 TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used 76 77 78 TARGET_IPHONE_SIMULATOR - Generate code for running under iPhone Simulator 79 80 81 ****************************************************************************************************/ 82 83 84 /* 85 * gcc based compiler used on Mac OS X 86 */ 87 #if defined(__GNUC__) && ( defined(__FreeBSD__) || defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) ) || defined(__clang__) 88 #define TARGET_OS_MAC 1 89 #define TARGET_OS_WIN32 0 90 #define TARGET_OS_UNIX 0 91 #define TARGET_OS_EMBEDDED 0 92 #define TARGET_OS_IPHONE 0 93 #define TARGET_IPHONE_SIMULATOR 0 94 #if defined(__ppc__) 95 #define TARGET_CPU_PPC 1 96 #define TARGET_CPU_PPC64 0 97 #define TARGET_CPU_68K 0 98 #define TARGET_CPU_X86 0 99 #define TARGET_CPU_X86_64 0 100 #define TARGET_CPU_ARM 0 101 #define TARGET_CPU_ARM64 0 102 #define TARGET_CPU_MIPS 0 103 #define TARGET_CPU_SPARC 0 104 #define TARGET_CPU_ALPHA 0 105 #define TARGET_RT_LITTLE_ENDIAN 0 106 #define TARGET_RT_BIG_ENDIAN 1 107 #define TARGET_RT_64_BIT 0 108 #ifdef __MACOS_CLASSIC__ 109 #define TARGET_RT_MAC_CFM 1 110 #define TARGET_RT_MAC_MACHO 0 111 #else 112 #define TARGET_RT_MAC_CFM 0 113 #define TARGET_RT_MAC_MACHO 1 114 #endif 115 #elif defined(__ppc64__) 116 #define TARGET_CPU_PPC 0 117 #define TARGET_CPU_PPC64 1 118 #define TARGET_CPU_68K 0 119 #define TARGET_CPU_X86 0 120 #define TARGET_CPU_X86_64 0 121 #define TARGET_CPU_ARM 0 122 #define TARGET_CPU_ARM64 0 123 #define TARGET_CPU_MIPS 0 124 #define TARGET_CPU_SPARC 0 125 #define TARGET_CPU_ALPHA 0 126 #define TARGET_RT_LITTLE_ENDIAN 0 127 #define TARGET_RT_BIG_ENDIAN 1 128 #define TARGET_RT_64_BIT 1 129 #define TARGET_RT_MAC_CFM 0 130 #define TARGET_RT_MAC_MACHO 1 131 #elif defined(__i386__) 132 #define TARGET_CPU_PPC 0 133 #define TARGET_CPU_PPC64 0 134 #define TARGET_CPU_68K 0 135 #define TARGET_CPU_X86 1 136 #define TARGET_CPU_X86_64 0 137 #define TARGET_CPU_ARM 0 138 #define TARGET_CPU_ARM64 0 139 #define TARGET_CPU_MIPS 0 140 #define TARGET_CPU_SPARC 0 141 #define TARGET_CPU_ALPHA 0 142 #define TARGET_RT_MAC_CFM 0 143 #define TARGET_RT_MAC_MACHO 1 144 #define TARGET_RT_LITTLE_ENDIAN 1 145 #define TARGET_RT_BIG_ENDIAN 0 146 #define TARGET_RT_64_BIT 0 147 #elif defined(__x86_64__) 148 #define TARGET_CPU_PPC 0 149 #define TARGET_CPU_PPC64 0 150 #define TARGET_CPU_68K 0 151 #define TARGET_CPU_X86 0 152 #define TARGET_CPU_X86_64 1 153 #define TARGET_CPU_ARM 0 154 #define TARGET_CPU_ARM64 0 155 #define TARGET_CPU_MIPS 0 156 #define TARGET_CPU_SPARC 0 157 #define TARGET_CPU_ALPHA 0 158 #define TARGET_RT_MAC_CFM 0 159 #define TARGET_RT_MAC_MACHO 1 160 #define TARGET_RT_LITTLE_ENDIAN 1 161 #define TARGET_RT_BIG_ENDIAN 0 162 #define TARGET_RT_64_BIT 1 163 #elif defined(__sparc64__) 164 #define TARGET_CPU_PPC 0 165 #define TARGET_CPU_PPC64 0 166 #define TARGET_CPU_68K 0 167 #define TARGET_CPU_X86 0 168 #define TARGET_CPU_X86_64 0 169 #define TARGET_CPU_ARM 0 170 #define TARGET_CPU_ARM64 0 171 #define TARGET_CPU_MIPS 0 172 #define TARGET_CPU_SPARC 1 173 #define TARGET_CPU_ALPHA 0 174 #define TARGET_RT_MAC_CFM 0 175 #define TARGET_RT_MAC_MACHO 0 176 #define TARGET_RT_LITTLE_ENDIAN 0 177 #define TARGET_RT_BIG_ENDIAN 1 178 #define TARGET_RT_64_BIT 1 179 #elif defined(__arm__) 180 #define TARGET_CPU_PPC 0 181 #define TARGET_CPU_PPC64 0 182 #define TARGET_CPU_68K 0 183 #define TARGET_CPU_X86 0 184 #define TARGET_CPU_X86_64 0 185 #define TARGET_CPU_ARM 1 186 #define TARGET_CPU_ARM64 0 187 #define TARGET_CPU_MIPS 0 188 #define TARGET_CPU_SPARC 0 189 #define TARGET_CPU_ALPHA 0 190 #define TARGET_RT_MAC_CFM 0 191 #define TARGET_RT_MAC_MACHO 1 192 #define TARGET_RT_LITTLE_ENDIAN 1 193 #define TARGET_RT_BIG_ENDIAN 0 194 #define TARGET_RT_64_BIT 0 195 #elif defined(__arm64__) 196 #define TARGET_CPU_PPC 0 197 #define TARGET_CPU_PPC64 0 198 #define TARGET_CPU_68K 0 199 #define TARGET_CPU_X86 0 200 #define TARGET_CPU_X86_64 0 201 #define TARGET_CPU_ARM 0 202 #define TARGET_CPU_ARM64 1 203 #define TARGET_CPU_MIPS 0 204 #define TARGET_CPU_SPARC 0 205 #define TARGET_CPU_ALPHA 0 206 #define TARGET_RT_MAC_CFM 0 207 #define TARGET_RT_MAC_MACHO 1 208 #define TARGET_RT_LITTLE_ENDIAN 1 209 #define TARGET_RT_BIG_ENDIAN 0 210 #define TARGET_RT_64_BIT 1 211 #else 212 #error unrecognized GNU C compiler 213 #endif 214 215 216 217 /* 218 * CodeWarrior compiler from Metrowerks/Motorola 219 */ 220 #elif defined(__MWERKS__) 221 #define TARGET_OS_MAC 1 222 #define TARGET_OS_WIN32 0 223 #define TARGET_OS_UNIX 0 224 #define TARGET_OS_EMBEDDED 0 225 #if defined(__POWERPC__) 226 #define TARGET_CPU_PPC 1 227 #define TARGET_CPU_PPC64 0 228 #define TARGET_CPU_68K 0 229 #define TARGET_CPU_X86 0 230 #define TARGET_CPU_MIPS 0 231 #define TARGET_CPU_SPARC 0 232 #define TARGET_CPU_ALPHA 0 233 #define TARGET_RT_LITTLE_ENDIAN 0 234 #define TARGET_RT_BIG_ENDIAN 1 235 #elif defined(__INTEL__) 236 #define TARGET_CPU_PPC 0 237 #define TARGET_CPU_PPC64 0 238 #define TARGET_CPU_68K 0 239 #define TARGET_CPU_X86 1 240 #define TARGET_CPU_MIPS 0 241 #define TARGET_CPU_SPARC 0 242 #define TARGET_CPU_ALPHA 0 243 #define TARGET_RT_LITTLE_ENDIAN 1 244 #define TARGET_RT_BIG_ENDIAN 0 245 #else 246 #error unknown Metrowerks CPU type 247 #endif 248 #define TARGET_RT_64_BIT 0 249 #ifdef __MACH__ 250 #define TARGET_RT_MAC_CFM 0 251 #define TARGET_RT_MAC_MACHO 1 252 #else 253 #define TARGET_RT_MAC_CFM 1 254 #define TARGET_RT_MAC_MACHO 0 255 #endif 256 257 /* 258 * unknown compiler 259 */ 260 #else 261 #if defined(TARGET_CPU_PPC) && TARGET_CPU_PPC 262 #define TARGET_CPU_PPC64 0 263 #define TARGET_CPU_68K 0 264 #define TARGET_CPU_X86 0 265 #define TARGET_CPU_X86_64 0 266 #define TARGET_CPU_ARM 0 267 #define TARGET_CPU_ARM64 0 268 #define TARGET_CPU_MIPS 0 269 #define TARGET_CPU_SPARC 0 270 #define TARGET_CPU_ALPHA 0 271 #elif defined(TARGET_CPU_PPC64) && TARGET_CPU_PPC64 272 #define TARGET_CPU_PPC 0 273 #define TARGET_CPU_68K 0 274 #define TARGET_CPU_X86 0 275 #define TARGET_CPU_X86_64 0 276 #define TARGET_CPU_ARM 0 277 #define TARGET_CPU_ARM64 0 278 #define TARGET_CPU_MIPS 0 279 #define TARGET_CPU_SPARC 0 280 #define TARGET_CPU_ALPHA 0 281 #elif defined(TARGET_CPU_X86) && TARGET_CPU_X86 282 #define TARGET_CPU_PPC 0 283 #define TARGET_CPU_PPC64 0 284 #define TARGET_CPU_X86_64 0 285 #define TARGET_CPU_68K 0 286 #define TARGET_CPU_ARM 0 287 #define TARGET_CPU_ARM64 0 288 #define TARGET_CPU_MIPS 0 289 #define TARGET_CPU_SPARC 0 290 #define TARGET_CPU_ALPHA 0 291 #elif defined(TARGET_CPU_X86_64) && TARGET_CPU_X86_64 292 #define TARGET_CPU_PPC 0 293 #define TARGET_CPU_PPC64 0 294 #define TARGET_CPU_X86 0 295 #define TARGET_CPU_68K 0 296 #define TARGET_CPU_ARM 0 297 #define TARGET_CPU_ARM64 0 298 #define TARGET_CPU_MIPS 0 299 #define TARGET_CPU_SPARC 0 300 #define TARGET_CPU_ALPHA 0 301 #elif defined(TARGET_CPU_ARM) && TARGET_CPU_ARM 302 #define TARGET_CPU_PPC 0 303 #define TARGET_CPU_PPC64 0 304 #define TARGET_CPU_X86 0 305 #define TARGET_CPU_X86_64 0 306 #define TARGET_CPU_68K 0 307 #define TARGET_CPU_ARM64 0 308 #define TARGET_CPU_MIPS 0 309 #define TARGET_CPU_SPARC 0 310 #define TARGET_CPU_ALPHA 0 311 #elif defined(TARGET_CPU_ARM64) && TARGET_CPU_ARM64 312 #define TARGET_CPU_PPC 0 313 #define TARGET_CPU_PPC64 0 314 #define TARGET_CPU_X86 0 315 #define TARGET_CPU_X86_64 0 316 #define TARGET_CPU_68K 0 317 #define TARGET_CPU_ARM 0 318 #define TARGET_CPU_MIPS 0 319 #define TARGET_CPU_SPARC 0 320 #define TARGET_CPU_ALPHA 0 321 #else 322 /* 323 NOTE: If your compiler errors out here then support for your compiler 324 has not yet been added to TargetConditionals.h. 325 326 TargetConditionals.h is designed to be plug-and-play. It auto detects 327 which compiler is being run and configures the TARGET_ conditionals 328 appropriately. 329 330 The short term work around is to set the TARGET_CPU_ and TARGET_OS_ 331 on the command line to the compiler (e.g. -DTARGET_CPU_MIPS=1 -DTARGET_OS_UNIX=1) 332 333 The long term solution is to add a new case to this file which 334 auto detects your compiler and sets up the TARGET_ conditionals. 335 Then submit the changes to Apple Computer. 336 */ 337 #error TargetConditionals.h: unknown compiler (see comment above) 338 #define TARGET_CPU_PPC 0 339 #define TARGET_CPU_68K 0 340 #define TARGET_CPU_X86 0 341 #define TARGET_CPU_ARM 0 342 #define TARGET_CPU_ARM64 0 343 #define TARGET_CPU_MIPS 0 344 #define TARGET_CPU_SPARC 0 345 #define TARGET_CPU_ALPHA 0 346 #endif 347 #define TARGET_OS_MAC 1 348 #define TARGET_OS_WIN32 0 349 #define TARGET_OS_UNIX 0 350 #define TARGET_OS_EMBEDDED 0 351 #if TARGET_CPU_PPC || TARGET_CPU_PPC64 352 #define TARGET_RT_BIG_ENDIAN 1 353 #define TARGET_RT_LITTLE_ENDIAN 0 354 #else 355 #define TARGET_RT_BIG_ENDIAN 0 356 #define TARGET_RT_LITTLE_ENDIAN 1 357 #endif 358 #if TARGET_CPU_PPC64 || TARGET_CPU_X86_64 359 #define TARGET_RT_64_BIT 1 360 #else 361 #define TARGET_RT_64_BIT 0 362 #endif 363 #ifdef __MACH__ 364 #define TARGET_RT_MAC_MACHO 1 365 #define TARGET_RT_MAC_CFM 0 366 #else 367 #define TARGET_RT_MAC_MACHO 0 368 #define TARGET_RT_MAC_CFM 1 369 #endif 370 371 #endif 372 373 #endif /* __TARGETCONDITIONALS__ */ 374