home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / c / cpp.lha / cppdef.h < prev    next >
C/C++ Source or Header  |  1991-10-19  |  14KB  |  526 lines

  1. /*
  2.  
  3.  
  4.  Copyright (C) 1990 Texas Instruments Incorporated.
  5.  
  6.  Permission is granted to any individual or institution to use, copy, modify,
  7.  and distribute this software, provided that this complete copyright and
  8.  permission notice is maintained, intact, in all copies and supporting
  9.  documentation.
  10.  
  11.  Texas Instruments Incorporated provides this software "as is" without
  12.  express or implied warranty.
  13.  
  14.  
  15.  *                 S y s t e m   D e p e n d e n t
  16.  *              D e f i n i t i o n s    f o r   C P P
  17.  *
  18.  * Definitions in this file may be edited to configure CPP for particular
  19.  * host operating systems and target configurations.
  20.  *
  21.  * NOTE: cpp assumes it is compiled by a compiler that supports macros
  22.  * with arguments.  If this is not the case (as for Decus C), #define
  23.  * nomacarg -- and provide function equivalents for all macros.
  24.  *
  25.  * cpp also assumes the host and target implement the Ascii character set.
  26.  * If this is not the case, you will have to do some editing here and there.
  27.  *
  28.  *  Change History
  29.  *  19-Jan-90  DKM  Support for MVS and EBCDIC character set
  30.  *  04-May-90  MJF  Added predefined constant "sun"
  31.  *  16-Jun-91  GPD  Fixed predefines for sun, pyr and i386 architectures
  32.  *
  33.  *  29-Jul-91  PB   Added support for AmigaOS using SAS/C
  34.  */
  35.  
  36. #ifndef CPPDEFH
  37. #define CPPDEFH
  38.  
  39. #ifdef EMACS
  40.  
  41. /* Use the Emacs config file to find out what type of machine */
  42.  
  43. #define NO_SHORTNAMES
  44. #include "../src/config.h"
  45.  
  46. /* Convert Emacs's conventions for BIG_ENDIAN to cpp's convention.  */
  47. #ifdef BIG_ENDIAN
  48. #undef BIG_ENDIAN
  49. #define BIG_ENDIAN TRUE
  50. #else /* not BIG_ENDIAN */
  51. #define BIG_ENDIAN FALSE
  52. #endif /* BIG_ENDIAN */
  53.  
  54. /* Emacs uses the names index and rindex and defines them as str(r)chr if nec;
  55.    cpp uses the opposite convention.  Here we flush the macro definitions for
  56.    Emacs and add the ones cpp wants.  */
  57.  
  58. #ifdef index
  59. #undef index
  60. #undef rindex
  61. #else /* index is not defined as a macro */
  62. #define strchr index
  63. #define strrchr rindex
  64. #endif /* index is not defined as a macro */
  65.  
  66. #define NBUFF 2048
  67. #define NWORK 2048
  68.  
  69. #endif /* EMACS */
  70.  
  71. /*
  72.  * This redundant definition of TRUE and FALSE works around
  73.  * a limitation of Decus C.
  74.  */
  75. #ifndef TRUE
  76. #define TRUE                    1
  77. #define FALSE                   0
  78. #endif
  79.  
  80. /*
  81.  * Define the HOST operating system.  This is needed so that
  82.  * cpp can use appropriate filename conventions.
  83.  */
  84. #define SYS_UNKNOWN             0
  85. #define SYS_UNIX                1
  86. #define SYS_VMS                 2
  87. #define SYS_RSX                 3
  88. #define SYS_RT11                4
  89. #define SYS_LATTICE             5
  90. #define SYS_ONYX                6
  91. #define SYS_68000               7
  92. #define SYS_OS2                 8
  93. #define SYS_XENIX               9
  94. #define SYS_MVS                 10
  95. #define SYS_AIX                 11
  96. #define SYS_AMIGA               12
  97.  
  98. /* Both ASCII and EBCDIC machines are supported  */
  99. #define ASCII                   1
  100. #define EBCDIC                  2
  101.  
  102. #ifndef HOST
  103. #ifdef  unix
  104. #define HOST                    SYS_UNIX
  105. #else
  106. #ifdef  vms
  107. #define HOST                    SYS_VMS
  108. #else
  109. #ifdef  rsx
  110. #define HOST                    SYS_RSX
  111. #else
  112. #ifdef  rt11
  113. #define HOST                    SYS_RT11
  114. #else
  115. #if defined(DOS) || defined(MSDOS)
  116. #define HOST                    SYS_OS2
  117. #else
  118. #ifdef  M_XENIX
  119. #define HOST                    SYS_XENIX
  120. #else
  121. #ifdef  SYS_OSVS
  122. #define HOST                    SYS_MVS
  123. #else
  124. #if defined(_AIX)
  125. #define HOST                    SYS_AIX
  126. #else
  127. #ifdef AMIGA
  128. #define HOST                    SYS_AMIGA
  129. #endif
  130. #endif
  131. #endif
  132. #endif
  133. #endif
  134. #endif
  135. #endif
  136. #endif
  137. #endif
  138. #endif
  139.  
  140. #ifndef HOST
  141. #define HOST                    SYS_UNKNOWN
  142. #endif
  143.  
  144. /*
  145.  * We assume that the target is the same as the host system
  146.  */
  147. #ifndef TARGET
  148. #define TARGET                  HOST
  149. #endif
  150.  
  151. /*
  152.  * In order to predefine machine-dependent constants,
  153.  * several strings are defined here:
  154.  *
  155.  * MACHINE      defines the target cpu (by name)
  156.  * SYSTEM       defines the target operating system
  157.  * COMPILER     defines the target compiler
  158.  * CHARSET      character set used, ASCII or EBCDIC (defaults ASCII).
  159.  *
  160.  *      The above may be #defined as "" if they are not wanted.
  161.  *      They should not be #defined as NULL.
  162.  *
  163.  * LINE_PREFIX  defines the # output line prefix, if not "line"
  164.  *              This should be defined as "" if cpp is to replace
  165.  *              the "standard" C pre-processor.
  166.  *
  167.  * FILE_LOCAL   marks functions which are referenced only in the
  168.  *              file they reside.  Some C compilers allow these
  169.  *              to be marked "static" even though they are referenced
  170.  *              by "extern" statements elsewhere.
  171.  *
  172.  * OK_DOLLAR    Should be set TRUE if $ is a valid alphabetic character
  173.  *              in identifiers (default), or zero if $ is invalid.
  174.  *              Default is TRUE.
  175.  *
  176.  * OK_CONCAT    Should be set TRUE if ## may be used to concatenate
  177.  *              tokens in macros (per the Ansi Draft Standard) or
  178.  *              FALSE for old-style # processing (needed if cpp is
  179.  *              to process assembler source code).
  180.  *
  181.  * OK_DATE      Predefines the compilation date if set TRUE.
  182.  *              Not permitted by the Nov. 12, 1984 Draft Standard.
  183.  *
  184.  * S_CHAR etc.  Define the sizeof the basic TARGET machine word types.
  185.  *              By default, sizes are set to the values for the HOST
  186.  *              computer.  If this is inappropriate, see the code in
  187.  *              cpp3.c for details on what to change.  Also, if you
  188.  *              have a machine where sizeof (signed int) differs from
  189.  *              sizeof (unsigned int), you will have to edit code and
  190.  *              tables in cpp3.c (and extend the -S option definition.)
  191.  *
  192.  * CPP_LIBRARY  May be defined if you have a site-specific include directory
  193.  *              which is to be searched *before* the operating-system
  194.  *              specific directories.
  195.  */
  196.  
  197. #if TARGET == SYS_LATTICE
  198. /*
  199.  * We assume the operating system is pcdos for the IBM-PC.
  200.  * We also assume the small model (just like the PDP-11)
  201.  */
  202. #define MACHINE                 "i8086"
  203. #define SYSTEM                  "pcdos"
  204. #endif
  205.  
  206. #if TARGET == SYS_ONYX
  207. #define MACHINE                 "z8000"
  208. #define SYSTEM                  "unix"
  209. #endif
  210.  
  211. #if TARGET == SYS_VMS
  212. #define MACHINE                 "vax"
  213. #define SYSTEM                  "vms"
  214. #define COMPILER                "vax11c"
  215. #endif
  216.  
  217. #if TARGET == SYS_RSX
  218. #define MACHINE                 "pdp11"
  219. #define SYSTEM                  "rsx"
  220. #define COMPILER                "decus"
  221. #endif
  222.  
  223. #if TARGET == SYS_RT11
  224. #define MACHINE                 "pdp11"
  225. #define SYSTEM                  "rt11"
  226. #define COMPILER                "decus"
  227. #endif
  228.  
  229. #if TARGET == SYS_XENIX
  230. #define MACHINE                 "I80386"
  231. #define SYSTEM                  "M_XENIX"
  232. #define COMPILER                "XENIXC"
  233. #endif
  234.  
  235. #if TARGET == SYS_OS2
  236. #define MACHINE                 "I80386"
  237. #define SYSTEM                  "DOS"
  238. #define COMPILER                "IBMC2"
  239. #endif
  240.  
  241. #if TARGET == SYS_MVS
  242. #define MACHINE                 "IBM370"
  243. #define SYSTEM                  "MVS"
  244. #define COMPILER                "SAS/C"
  245. #define CHARSET                 EBCDIC
  246. #endif
  247.  
  248. #if TARGET == SYS_AIX
  249. #define MACHINE                 "RS6000"
  250. #define SYSTEM                  "AIX"
  251. #define COMPILER                "IBMCC"
  252. #endif
  253.  
  254. #if TARGET == SYS_68000
  255. /*
  256.  * All three machine designators have been seen in various systems.
  257.  * Warning -- compilers differ as to sizeof (int).  cpp3 assumes that
  258.  * sizeof (int) == 2
  259.  */
  260. #define MACHINE                 "M68000", "m68000", "m68k"
  261. #define SYSTEM                  "unix"
  262. #endif
  263.  
  264. #if     TARGET == SYS_UNIX
  265. #define SYSTEM                  "unix"
  266. #ifdef  pdp11
  267. #define MACHINE                 "pdp11"
  268. #endif
  269. #ifdef  vax
  270. #define MACHINE                 "vax"
  271. #endif
  272. #ifdef  sparc
  273. #define MACHINE                 "sparc"
  274. #endif
  275. #ifdef  mc68020
  276. #define MACHINE                 "mc68020", "mc68000"
  277. #endif
  278. #ifdef  sun
  279. #define TARGET_ARCH             "sun"
  280. #endif
  281. #ifdef  pyr
  282. #define MACHINE                 "pyr"
  283. #endif
  284. #ifdef  i386
  285. #define MACHINE                 "i386"
  286. #endif
  287. #endif
  288.  
  289. #if     TARGET == SYS_AMIGA
  290. #define SYSTEM                  "AMIGA"
  291. #define COMMENT_INVISIBLE       TRUE
  292. #define ONLY_WS_BEFORE_CONTROL  TRUE
  293. #define SKIP_LEADING_BLANKS     FALSE
  294. #endif
  295.  
  296. /*
  297.  * defaults
  298.  */
  299.  
  300. #ifndef CHARSET
  301. #define CHARSET                 ASCII
  302. #endif
  303.  
  304. #ifndef MSG_PREFIX
  305. #define MSG_PREFIX              "cpp: "
  306. #endif
  307.  
  308. #ifndef LINE_PREFIX
  309. #ifdef  decus
  310. #define LINE_PREFIX             ""
  311. #else
  312. #define LINE_PREFIX             "line"
  313. #endif
  314. #endif
  315.  
  316. /* create a string that can be shoved on the preset symbols list
  317.  * so programs running this cpp can test for ASCII or EBCDIC too.
  318.  */
  319. #if CHARSET == EBCDIC
  320. #define CH_SET                  "EBCDIC"
  321. #else
  322. #define CH_SET                  "ASCII"
  323. #endif
  324.  
  325.  
  326. /*
  327.  * OLD_PREPROCESSOR forces the definition of OK_DOLLAR, OK_CONCAT,
  328.  * COMMENT_INVISIBLE, and STRING_FORMAL to values appropriate for
  329.  * an old-style preprocessor.
  330.  */
  331.  
  332. #if     OLD_PREPROCESSOR
  333. #define OK_DOLLAR               FALSE
  334. #define OK_CONCAT               FALSE
  335. #define COMMENT_INVISIBLE       TRUE
  336. #define STRING_FORMAL           TRUE
  337. #endif
  338.  
  339. /*
  340.  * RECURSION_LIMIT may be set to -1 to disable the macro recursion test.
  341.  */
  342. #ifndef RECURSION_LIMIT
  343. #define RECURSION_LIMIT 1000
  344. #endif
  345.  
  346. /*
  347.  * BITS_CHAR may be defined to set the number of bits per character.
  348.  * it is needed only for multi-byte character constants.
  349.  */
  350. #ifndef BITS_CHAR
  351. #define BITS_CHAR               8
  352. #endif
  353.  
  354. /*
  355.  * BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series)
  356.  * where 'ab' stores 'a' in the high-bits and 'b' in the low-bits.
  357.  * It is set FALSE on machines (such as the PDP-11 and Vax-11)
  358.  * where 'ab' stores 'a' in the low-bits and 'b' in the high-bits.
  359.  * (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested.
  360.  */
  361. #ifndef BIG_ENDIAN
  362. #if (HOST == SYS_MVS) || defined(i386)
  363. #define BIG_ENDIAN              TRUE      /* Is this right??? */
  364. #else
  365. #define BIG_ENDIAN              FALSE
  366. #endif
  367. #endif
  368.  
  369. /*
  370.  * COMMENT_INVISIBLE may be defined to allow "old-style" comment
  371.  * processing, whereby the comment becomes a zero-length token
  372.  * delimiter.  This permitted tokens to be concatenated in macro
  373.  * expansions.  This was removed from the Draft Ansi Standard.
  374.  */
  375. #ifndef COMMENT_INVISIBLE
  376. #define COMMENT_INVISIBLE       FALSE
  377. #endif
  378.  
  379. /*
  380.  * ONLY_WS_BEFORE_CONTROL may be defined to have cpp ignore #control
  381.  * lines which are preceded by comments and whitespace.  Currently
  382.  * only works together with COMMENT_INVISIBLE.
  383.  */
  384. #ifndef ONLY_WS_BEFORE_CONTROL
  385. #define ONLY_WS_BEFORE_CONTROL  FALSE
  386. #endif
  387.  
  388. /*
  389.  * SKIP_LEADING_BLANKS may be undefined to disable skipping initial
  390.  * blanks.  This will preserve indention.
  391.  */
  392. #ifndef SKIP_LEADING_BLANKS
  393. #define SKIP_LEADING_BLANKS     TRUE
  394. #endif
  395.  
  396. /*
  397.  * STRING_FORMAL may be defined to allow recognition of macro parameters
  398.  * anywhere in replacement strings.  This was removed from the Draft Ansi
  399.  * Standard and a limited recognition capability added.
  400.  */
  401. #ifndef STRING_FORMAL
  402. #define STRING_FORMAL           FALSE
  403. #endif
  404.  
  405. /*
  406.  * OK_DOLLAR enables use of $ as a valid "letter" in identifiers.
  407.  * This is a permitted extension to the Ansi Standard and is required
  408.  * for e.g., VMS, RSX-11M, etc.   It should be set FALSE if cpp is
  409.  * used to preprocess assembler source on Unix systems.  OLD_PREPROCESSOR
  410.  * sets OK_DOLLAR FALSE for that reason.
  411.  */
  412. #ifndef OK_DOLLAR
  413. #define OK_DOLLAR               TRUE
  414. #endif
  415.  
  416. /*
  417.  * OK_CONCAT enables (one possible implementation of) token concatenation.
  418.  * If cpp is used to preprocess Unix assembler source, this should be
  419.  * set FALSE as the concatenation character, #, is used by the assembler.
  420.  */
  421. #ifndef OK_CONCAT
  422. #define OK_CONCAT               TRUE
  423. #endif
  424.  
  425. /*
  426.  * OK_DATE may be enabled to predefine today's date as a string
  427.  * at the start of each compilation.  This is apparently not permitted
  428.  * by the Draft Ansi Standard.
  429.  */
  430. #ifndef OK_DATE
  431. #define OK_DATE         TRUE
  432. #endif
  433.  
  434. /*
  435.  * Some common definitions.
  436.  */
  437.  
  438. #ifndef DEBUG
  439. #define DEBUG                   FALSE
  440. #endif
  441.  
  442. /*
  443.  * The following definitions are used to allocate memory for
  444.  * work buffers.  In general, they should not be modified
  445.  * by implementors.
  446.  *
  447.  * PAR_MAC      The maximum number of #define parameters (31 per Standard)
  448.  *              Note: we need another one for strings.
  449.  * NBUFF        Input buffer size
  450.  * NWORK        Work buffer size -- the longest macro
  451.  *              must fit here after expansion.
  452.  * NEXP         The nesting depth of #if expressions
  453.  * NINCLUDE     The number of directories that may be specified
  454.  *              on a per-system basis, or by the -I option.
  455.  * BLK_NEST     The number of nested #if's permitted.
  456.  */
  457.  
  458. #ifndef PAR_MAC
  459. #define PAR_MAC            (31 + 1)
  460. #endif
  461.  
  462. #ifndef NBUFF
  463. #define NBUFF                   512
  464. #endif
  465.  
  466. #ifndef NWORK
  467. #define NWORK                   4096
  468. #endif
  469.  
  470. #ifndef NEXP
  471. #define NEXP                    128
  472. #endif
  473.  
  474. #ifndef NINCLUDE
  475. #define NINCLUDE                16
  476. #endif
  477.  
  478. #ifndef NPARMWORK
  479. #define NPARMWORK               (NBUFF * 2)
  480. #endif
  481.  
  482. #ifndef BLK_NEST
  483. #define BLK_NEST                32
  484. #endif
  485.  
  486.  
  487. /*
  488.  * Some special constants.  These may need to be changed if cpp
  489.  * is ported to a wierd machine.
  490.  *
  491.  * NOTE: if cpp is run on a non-ascii machine, ALERT and VT may
  492.  * need to be changed.  They are used to implement the proposed
  493.  * ANSI standard C control characters '\a' and '\v' only.
  494.  * DEL is used to tag macro tokens to prevent #define foo foo
  495.  * from looping.  Note that we don't try to prevent more elaborate
  496.  * #define loops from occurring.
  497.  */
  498.  
  499. #ifndef ALERT
  500. # if CHARSET == EBCDIC
  501. #    define ALERT                   '\057'      /* EBCDIC '\a' Bell */
  502. # else
  503. #    define ALERT                   '\007'      /* ASCII  '\a' Bell */
  504. #endif
  505. #endif
  506.  
  507. #ifndef VT
  508. #define VT                      '\013'          /* Vertical Tab CTRL/K  */
  509. #endif
  510.  
  511.  
  512. #ifndef FILE_LOCAL
  513. #ifdef  decus
  514. #define FILE_LOCAL              static
  515. #else
  516. #ifdef  vax11c
  517. #define FILE_LOCAL              static
  518. #else
  519. #define FILE_LOCAL                              /* Others are global    */
  520. #endif
  521. #endif
  522. #endif
  523.  
  524. #endif
  525.  
  526.