home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / ConditionalMacros.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-12  |  8.5 KB  |  256 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        ConditionalMacros.h
  3.  
  4.      Contains:    Compile time feature switches to achieve platform independent sources.
  5.  
  6.      Version:    Technology:    Universal Interface Files 2.0
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CONDITIONALMACROS__
  21. #define __CONDITIONALMACROS__
  22.  
  23. /*
  24.     This file sets up the following compiler independent conditionals:
  25.     
  26.     GENERATINGPOWERPC        - Compiler is generating PowerPC instructions
  27.     GENERATING68K            - Compiler is generating 68k family instructions
  28.     GENERATING68881            - Compiler is generating mc68881 floating point instructions
  29.     GENERATINGCFM            - Code being generated assumes CFM calling conventions
  30.     CFMSYSTEMCALLS            - No A-traps.  Systems calls are made using CFM and UPP's
  31.     
  32.     SystemSevenFiveOrLater    - Compiled code will only be run on a System 7.5 or later Macintosh
  33.     SystemSevenOrLater        - Compiled code will only be run on a System 7.0 or later Macintosh
  34.     SystemSixOrLater        - Compiled code will only be run on a System 6.0 or later Macintosh
  35.                               A developer should set the appropriate flag on the compiler command-
  36.                               line or in a file processed before this file.  This will allow the
  37.                               certain optimizations to be made which can result in smaller, faster
  38.                               applications.
  39.     
  40.     CGLUESUPPORTED            - Interface library will support "C glue" functions (function names
  41.                               are: all lowercase, use C strings instead of pascal strings, use 
  42.                               Point* instead of Point).
  43.  
  44.     OLDROUTINENAMES            - "Old" names for Macintosh system calls are allowed in source code.
  45.                               (e.g. DisposPtr instead of DisposePtr). The names of system routine
  46.                               are now more sensitive to change because CFM binds by name.  In the 
  47.                               past, system routine names were compiled out to just an A-Trap.  
  48.                               Macros have been added that each map an old name to its new name.  
  49.                               This allows old routine names to be used in existing source files,
  50.                               but the macros only work if OLDROUTINENAMES is true.  This support
  51.                               will be removed in the near future.  Thus, all source code should 
  52.                               be changed to use the new names! You can set OLDROUTINENAMES to false
  53.                               to see if your code has any old names left in it.
  54.     
  55.     OLDROUTINELOCATIONS     - "Old" location of Macintosh system calls are used.  For example, c2pstr 
  56.                               has been moved from Strings to TextUtils.  It is conditionalized in
  57.                               Strings with OLDROUTINELOCATIONS and in TextUtils with !OLDROUTINELOCATIONS.
  58.                               This allows developers to upgrade to newer interface files without suddenly
  59.                               all their code not compiling becuase of "incorrect" includes.  But, it
  60.                               allows the slow migration of system calls to more understandable file
  61.                               locations.  OLDROUTINELOCATIONS currently defaults to true, but eventually
  62.                               will default to false.
  63.     
  64.     PRAGMA_ALIGN_SUPPORTED    - Compiler supports "#pragma align=..." directives. The only compilers that
  65.                               can get by without supporting the pragma are old classic 68K compilers
  66.                               that will only be used to compile older structs that have 68K alignment
  67.                               anyways.  
  68.     
  69.     PRAGMA_IMPORT_SUPPORTED    - Compiler supports "#pragma import on/off" directives.  These directives
  70.                               were introduced with the SC compiler which supports CFM 68K.  The directive
  71.                               is used to tell the compiler which functions will be called through a 
  72.                               transition vector (instead of a simple PC-relative offset).  This allows 
  73.                               the compiler to generate better code.  Since System Software functions are
  74.                               implemented as shared libraries and called through transition vectors,
  75.                               all System Software functions are declared with "#pragma import on".
  76.                               
  77.     
  78.     There are some invariants among the conditionals:
  79.     
  80.     GENERATINGPOWERPC != GENERATING68K
  81.     GENERATING68881 => GENERATING68K
  82.     GENERATINGPOWERPC => GENERATINGCFM
  83.     GENERATINGPOWERPC => CFMSYSTEMCALLS
  84.     CFMSYSTEMCALLS => GENERATINGCFM
  85.     GENERATINGPOWERPC => SystemSevenOrLater
  86.     SystemSevenFiveOrLater => SystemSevenOrLater
  87.     SystemSevenOrLater => SystemSixOrLater
  88.     PRAGMA_IMPORT_SUPPORTED => CFMSYSTEMCALLS
  89.     
  90. */
  91. /*
  92.  
  93.     Set up GENERATINGPOWERPC and GENERATING68K
  94.  
  95. */
  96. #ifdef GENERATINGPOWERPC
  97.     #ifndef GENERATING68K
  98. #define GENERATING68K !GENERATINGPOWERPC
  99.     #endif
  100. #endif
  101. #ifdef GENERATING68K
  102.     #ifndef GENERATINGPOWERPC
  103. #define GENERATINGPOWERPC !GENERATING68K
  104.     #endif
  105. #endif
  106. #ifndef GENERATINGPOWERPC
  107.     #if defined(powerc) || defined(__powerc)
  108. #define GENERATINGPOWERPC 1
  109.     #else
  110. #define GENERATINGPOWERPC 0
  111.     #endif
  112. #endif
  113. #ifndef GENERATING68K
  114.     #if GENERATINGPOWERPC
  115. #define GENERATING68K 0
  116.     #else
  117. #define GENERATING68K 1
  118.     #endif
  119. #endif
  120. /*
  121.  
  122.     Set up GENERATING68881 
  123.  
  124. */
  125. #if GENERATING68K
  126.     #if defined(applec) || defined(__SC__)
  127.         #ifdef mc68881
  128. #define GENERATING68881 1
  129.         #endif
  130.     #else
  131.         #ifdef __MWERKS__
  132.             #if __MC68881__
  133. #define GENERATING68881 1
  134.             #endif
  135.         #endif
  136.     #endif
  137. #endif
  138. #ifndef GENERATING68881
  139. #define GENERATING68881 0
  140. #endif
  141. /*
  142.  
  143.     Set up GENERATINGCFM and  CFMSYSTEMCALLS
  144.  
  145. */
  146. #if GENERATINGPOWERPC || defined(__CFM68K__)
  147. #define GENERATINGCFM 1
  148. #define CFMSYSTEMCALLS 1
  149. #else
  150. #define GENERATINGCFM 0
  151. #define CFMSYSTEMCALLS 0
  152. #endif
  153. /*
  154.  
  155.     Set up SystemSevenFiveOrLater, SystemSevenOrLater, and SystemSixOrLater
  156.  
  157. */
  158. #ifndef SystemSevenFiveOrLater
  159. #define SystemSevenFiveOrLater 0
  160. #endif
  161. #ifndef SystemSevenOrLater
  162.     #if GENERATINGCFM
  163. #define SystemSevenOrLater 1
  164.     #else
  165. #define SystemSevenOrLater SystemSevenFiveOrLater
  166.     #endif
  167. #endif
  168. #ifndef SystemSixOrLater
  169. #define SystemSixOrLater SystemSevenOrLater
  170. #endif
  171. /*
  172.  
  173.     Set up OLDROUTINENAMES and OLDROUTINELOCATIONS
  174.  
  175. */
  176. #ifndef OLDROUTINENAMES
  177. #define OLDROUTINENAMES 1
  178. #endif
  179. #ifndef OLDROUTINELOCATIONS
  180. #define OLDROUTINELOCATIONS 1
  181. #endif
  182. /*
  183.  
  184.     Define C specific conditionals
  185.  
  186. */
  187. #ifndef CGLUESUPPORTED
  188.     #ifdef THINK_C
  189. #define CGLUESUPPORTED 0
  190.     #else
  191. #define CGLUESUPPORTED 1
  192.     #endif
  193. #endif
  194. #ifndef PRAGMA_ALIGN_SUPPORTED
  195.     #if GENERATINGPOWERPC || defined(__MWERKS__)
  196. #define PRAGMA_ALIGN_SUPPORTED 1
  197.     #else
  198. #define PRAGMA_ALIGN_SUPPORTED 0
  199.     #endif
  200. #endif
  201. #define STRUCTALIGNMENTSUPPORTED PRAGMA_ALIGN_SUPPORTED
  202. #ifndef PRAGMA_IMPORT_SUPPORTED
  203.     #if __CFM68K__
  204. #define PRAGMA_IMPORT_SUPPORTED 1
  205.     #else
  206. #define PRAGMA_IMPORT_SUPPORTED 0
  207.     #endif
  208. #endif
  209. /*
  210.  
  211.     Set up old "USES..." conditionals to support 1.0 universal interface files
  212.  
  213.     The USESxxx names are old, but cannot be removed yet because source code that
  214.     uses them might still compile, but do the wrong thing. 
  215. */
  216. #ifndef USES68KINLINES
  217. #define USES68KINLINES GENERATING68K
  218. #endif
  219. #define USESCODEFRAGMENTS GENERATINGCFM
  220. #define USESROUTINEDESCRIPTORS GENERATINGCFM
  221. /*
  222.     The following macros isolate the use of inlines from the routine prototypes.
  223.     A routine prototype will always be followed by on of these inline macros with
  224.     a list of the opcodes to be inlined.  On the 68K side, the appropriate inline
  225.     code will be generated.  On platforms that use code fragments, the macros are
  226.     essentially NOPs.
  227. */
  228. #if CFMSYSTEMCALLS
  229. #define ONEWORDINLINE(trapNum)
  230. #define TWOWORDINLINE(w1,w2)
  231. #define THREEWORDINLINE(w1,w2,w3)
  232. #define FOURWORDINLINE(w1,w2,w3,w4)
  233. #define FIVEWORDINLINE(w1,w2,w3,w4,w5)
  234. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)
  235. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)
  236. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)
  237. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)
  238. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)
  239. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)
  240. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)
  241. #else
  242. #define ONEWORDINLINE(trapNum) = trapNum
  243. #define TWOWORDINLINE(w1,w2) = {w1,w2}
  244. #define THREEWORDINLINE(w1,w2,w3) = {w1,w2,w3}
  245. #define FOURWORDINLINE(w1,w2,w3,w4)  = {w1,w2,w3,w4}
  246. #define FIVEWORDINLINE(w1,w2,w3,w4,w5) = {w1,w2,w3,w4,w5}
  247. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)     = {w1,w2,w3,w4,w5,w6}
  248. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)      = {w1,w2,w3,w4,w5,w6,w7}
  249. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)      = {w1,w2,w3,w4,w5,w6,w7,w8}
  250. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9}
  251. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)  = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10}
  252. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11}
  253. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12}
  254. #endif
  255. #endif /* __CONDITIONALMACROS__ */
  256.