home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / ZCPP_JAE / CPPDEF.H < prev    next >
C/C++ Source or Header  |  1992-07-14  |  12KB  |  483 lines

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