Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

TargetConditionals.h

By: a guest on Dec 10th, 2012  |  syntax: C++  |  size: 12.79 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * Copyright (c) 2000-2008 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(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) )
  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_MIPS         0
  102.         #define TARGET_CPU_SPARC        0  
  103.         #define TARGET_CPU_ALPHA        0
  104.         #define TARGET_RT_LITTLE_ENDIAN 0
  105.         #define TARGET_RT_BIG_ENDIAN    1
  106.         #define TARGET_RT_64_BIT        0
  107.         #ifdef __MACOS_CLASSIC__
  108.            #define TARGET_RT_MAC_CFM    1
  109.            #define TARGET_RT_MAC_MACHO  0
  110.         #else
  111.            #define TARGET_RT_MAC_CFM    0
  112.            #define TARGET_RT_MAC_MACHO  1
  113.        #endif
  114.     #elif defined(__ppc64__)
  115.         #define TARGET_CPU_PPC          0
  116.         #define TARGET_CPU_PPC64        1
  117.         #define TARGET_CPU_68K          0
  118.         #define TARGET_CPU_X86          0
  119.         #define TARGET_CPU_X86_64       0
  120.         #define TARGET_CPU_ARM          0
  121.         #define TARGET_CPU_MIPS         0
  122.         #define TARGET_CPU_SPARC        0  
  123.         #define TARGET_CPU_ALPHA        0
  124.         #define TARGET_RT_LITTLE_ENDIAN 0
  125.         #define TARGET_RT_BIG_ENDIAN    1
  126.         #define TARGET_RT_64_BIT        1
  127.         #define TARGET_RT_MAC_CFM       0
  128.         #define TARGET_RT_MAC_MACHO     1
  129.      #elif defined(__i386__)
  130.         #define TARGET_CPU_PPC          0
  131.         #define TARGET_CPU_PPC64        0
  132.         #define TARGET_CPU_68K          0
  133.         #define TARGET_CPU_X86          1
  134.         #define TARGET_CPU_X86_64       0
  135.         #define TARGET_CPU_ARM          0
  136.         #define TARGET_CPU_MIPS         0
  137.         #define TARGET_CPU_SPARC        0
  138.         #define TARGET_CPU_ALPHA        0
  139.         #define TARGET_RT_MAC_CFM       0
  140.         #define TARGET_RT_MAC_MACHO     1
  141.         #define TARGET_RT_LITTLE_ENDIAN 1
  142.         #define TARGET_RT_BIG_ENDIAN    0
  143.         #define TARGET_RT_64_BIT        0
  144.      #elif defined(__x86_64__)
  145.         #define TARGET_CPU_PPC          0
  146.         #define TARGET_CPU_PPC64        0
  147.         #define TARGET_CPU_68K          0
  148.         #define TARGET_CPU_X86          0
  149.         #define TARGET_CPU_X86_64       1
  150.         #define TARGET_CPU_ARM          0
  151.         #define TARGET_CPU_MIPS         0
  152.         #define TARGET_CPU_SPARC        0
  153.         #define TARGET_CPU_ALPHA        0
  154.         #define TARGET_RT_MAC_CFM       0
  155.         #define TARGET_RT_MAC_MACHO     1
  156.         #define TARGET_RT_LITTLE_ENDIAN 1
  157.         #define TARGET_RT_BIG_ENDIAN    0
  158.         #define TARGET_RT_64_BIT        1
  159.      #elif defined(__arm__)
  160.         #define TARGET_CPU_PPC          0
  161.         #define TARGET_CPU_PPC64        0
  162.         #define TARGET_CPU_68K          0
  163.         #define TARGET_CPU_X86          0
  164.         #define TARGET_CPU_X86_64       0
  165.         #define TARGET_CPU_ARM          1
  166.         #define TARGET_CPU_MIPS         0
  167.         #define TARGET_CPU_SPARC        0
  168.         #define TARGET_CPU_ALPHA        0
  169.         #define TARGET_RT_MAC_CFM       0
  170.         #define TARGET_RT_MAC_MACHO     1
  171.         #define TARGET_RT_LITTLE_ENDIAN 1
  172.         #define TARGET_RT_BIG_ENDIAN    0
  173.         #define TARGET_RT_64_BIT        0
  174.     #else
  175.         #error unrecognized GNU C compiler
  176.     #endif
  177.  
  178.  
  179. /*
  180.  *   CodeWarrior compiler from Metrowerks/Motorola
  181.  */
  182. #elif defined(__MWERKS__)
  183.     #define TARGET_OS_MAC               1
  184.     #define TARGET_OS_WIN32             0
  185.     #define TARGET_OS_UNIX              0
  186.     #define TARGET_OS_EMBEDDED          0
  187.     #if defined(__POWERPC__)
  188.         #define TARGET_CPU_PPC          1
  189.         #define TARGET_CPU_PPC64        0
  190.         #define TARGET_CPU_68K          0
  191.         #define TARGET_CPU_X86          0
  192.         #define TARGET_CPU_MIPS         0
  193.         #define TARGET_CPU_SPARC        0
  194.         #define TARGET_CPU_ALPHA        0
  195.         #define TARGET_RT_LITTLE_ENDIAN 0
  196.         #define TARGET_RT_BIG_ENDIAN    1
  197.     #elif defined(__INTEL__)
  198.         #define TARGET_CPU_PPC          0
  199.         #define TARGET_CPU_PPC64        0
  200.         #define TARGET_CPU_68K          0
  201.         #define TARGET_CPU_X86          1
  202.         #define TARGET_CPU_MIPS         0
  203.         #define TARGET_CPU_SPARC        0
  204.         #define TARGET_CPU_ALPHA        0
  205.         #define TARGET_RT_LITTLE_ENDIAN 1
  206.         #define TARGET_RT_BIG_ENDIAN    0
  207.     #else
  208.         #error unknown Metrowerks CPU type
  209.     #endif
  210.     #define TARGET_RT_64_BIT            0
  211.     #ifdef __MACH__
  212.         #define TARGET_RT_MAC_CFM       0
  213.         #define TARGET_RT_MAC_MACHO     1
  214.     #else
  215.         #define TARGET_RT_MAC_CFM       1
  216.         #define TARGET_RT_MAC_MACHO     0
  217.     #endif
  218.  
  219. /*
  220.  *   unknown compiler
  221.  */
  222. #else
  223.     #if defined(TARGET_CPU_PPC) && TARGET_CPU_PPC
  224.         #define TARGET_CPU_PPC64    0
  225.         #define TARGET_CPU_68K      0
  226.         #define TARGET_CPU_X86      0
  227.         #define TARGET_CPU_X86_64   0
  228.         #define TARGET_CPU_ARM      0
  229.         #define TARGET_CPU_MIPS     0
  230.         #define TARGET_CPU_SPARC    0
  231.         #define TARGET_CPU_ALPHA    0
  232.     #elif defined(TARGET_CPU_PPC64) && TARGET_CPU_PPC64
  233.         #define TARGET_CPU_PPC      0
  234.         #define TARGET_CPU_68K      0
  235.         #define TARGET_CPU_X86      0
  236.         #define TARGET_CPU_X86_64   0
  237.         #define TARGET_CPU_ARM      0
  238.         #define TARGET_CPU_MIPS     0
  239.         #define TARGET_CPU_SPARC    0
  240.         #define TARGET_CPU_ALPHA    0
  241.     #elif defined(TARGET_CPU_X86) && TARGET_CPU_X86
  242.         #define TARGET_CPU_PPC      0
  243.         #define TARGET_CPU_PPC64    0
  244.         #define TARGET_CPU_X86_64   0
  245.         #define TARGET_CPU_68K      0
  246.         #define TARGET_CPU_ARM      0
  247.         #define TARGET_CPU_MIPS     0
  248.         #define TARGET_CPU_SPARC    0
  249.         #define TARGET_CPU_ALPHA    0
  250.     #elif defined(TARGET_CPU_X86_64) && TARGET_CPU_X86_64
  251.         #define TARGET_CPU_PPC      0
  252.         #define TARGET_CPU_PPC64    0
  253.         #define TARGET_CPU_X86      0
  254.         #define TARGET_CPU_68K      0
  255.         #define TARGET_CPU_ARM      0
  256.         #define TARGET_CPU_MIPS     0
  257.         #define TARGET_CPU_SPARC    0
  258.         #define TARGET_CPU_ALPHA    0
  259.     #elif defined(TARGET_CPU_ARM) && TARGET_CPU_ARM
  260.         #define TARGET_CPU_PPC      0
  261.         #define TARGET_CPU_PPC64    0
  262.         #define TARGET_CPU_X86      0
  263.         #define TARGET_CPU_X86_64   0
  264.         #define TARGET_CPU_68K      0
  265.         #define TARGET_CPU_MIPS     0
  266.         #define TARGET_CPU_SPARC    0
  267.         #define TARGET_CPU_ALPHA    0
  268.     #else
  269.         /*
  270.             NOTE:   If your compiler errors out here then support for your compiler
  271.             has not yet been added to TargetConditionals.h.  
  272.            
  273.             TargetConditionals.h is designed to be plug-and-play.  It auto detects
  274.             which compiler is being run and configures the TARGET_ conditionals
  275.             appropriately.  
  276.            
  277.             The short term work around is to set the TARGET_CPU_ and TARGET_OS_
  278.             on the command line to the compiler (e.g. -DTARGET_CPU_MIPS=1 -DTARGET_OS_UNIX=1)
  279.            
  280.             The long term solution is to add a new case to this file which
  281.             auto detects your compiler and sets up the TARGET_ conditionals.
  282.             Then submit the changes to Apple Computer.
  283.         */
  284.         #error TargetConditionals.h: unknown compiler (see comment above)
  285.         #define TARGET_CPU_PPC    0
  286.         #define TARGET_CPU_68K    0
  287.         #define TARGET_CPU_X86    0
  288.         #define TARGET_CPU_ARM    0
  289.         #define TARGET_CPU_MIPS   0
  290.         #define TARGET_CPU_SPARC  0
  291.         #define TARGET_CPU_ALPHA  0
  292.     #endif
  293.     #define TARGET_OS_MAC                1
  294.     #define TARGET_OS_WIN32              0
  295.     #define TARGET_OS_UNIX               0
  296.     #define TARGET_OS_EMBEDDED           0
  297.     #if TARGET_CPU_PPC || TARGET_CPU_PPC64
  298.         #define TARGET_RT_BIG_ENDIAN     1
  299.         #define TARGET_RT_LITTLE_ENDIAN  0
  300.     #else
  301.         #define TARGET_RT_BIG_ENDIAN     0
  302.         #define TARGET_RT_LITTLE_ENDIAN  1
  303.     #endif
  304.     #if TARGET_CPU_PPC64 || TARGET_CPU_X86_64
  305.         #define TARGET_RT_64_BIT         1
  306.     #else
  307.         #define TARGET_RT_64_BIT         0
  308.     #endif
  309.     #ifdef __MACH__
  310.         #define TARGET_RT_MAC_MACHO      1
  311.         #define TARGET_RT_MAC_CFM        0
  312.     #else
  313.         #define TARGET_RT_MAC_MACHO      0
  314.         #define TARGET_RT_MAC_CFM        1
  315.     #endif
  316.    
  317. #endif
  318.  
  319. #endif  /* __TARGETCONDITIONALS__ */