home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / fweb153.zip / fweb-1.53 / web / custom.web < prev    next >
Text File  |  1995-09-23  |  25KB  |  924 lines

  1. @z --- custom.web ---
  2.  
  3. FWEB version 1.53 (September 23, 1995)
  4.  
  5. Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
  6.  
  7. @x-----------------------------------------------------------------------------
  8.  
  9. \Title{CUSTOM.WEB} % Customization header file.
  10.  
  11. @c
  12. @* CUSTOMIZATION. 
  13. Customization refers to tayloring an already compilable \FWEB, as well as
  14. dealing with the annoyances of different compilers and operating systems. 
  15. Once you've gotten a workable processor, you could supply a change file for
  16. \.{custom.web} to maintain your changes from release to release. 
  17.  
  18. The source code includes the file \.{custom.h}. There are two fundamental
  19. ways of producing that file.
  20.  
  21. In the modern way (new with v1.30), a template file \.{custom.h.in} is
  22. produced.  This file is read by the configuration script \.{./configure},
  23. which figures out automatically the settings of various parameters
  24. appropriate for your system, then writes out \.{custom.h}.
  25.  
  26. In the old way, \.{custom.h} is created directly from \.{custom.web}, using
  27. conditional flags to handle the differences between machines.  
  28.  
  29. Conditional branches \It{in this file only} are determined by upper-case \WEB\
  30. macros, one of which should be defined from the command line (by saying,
  31. e.g., ``\.{-mIBMPC}'') or put into your \.{.fweb} file.  Currently, these
  32. macros are |CONFIG| (the special ``machine'' for automatic configuration), 
  33. |ANSI|, |BSD|, |DSU|, |IBMPC|, |MAC|, |MISC|, |SGI|,
  34. |SUN|, and |VAX|.  If you're working on the Sun and will be using \.{gcc}
  35. (highly recommended), you should also define |GCC|.  Use the |MISC| macro
  36. for working with your own customization.
  37.  
  38. \comment
  39. The current list of customization flags is as follows:
  40. $$\vbox{\halign{\.{#}\hfil&\ ---\ \vtop{\hsize=0.75\hsize\noindent
  41.     \strut#\strut}\hfil\cr
  42. machine&\It{Lower-case} name of the machine, such as ``\.{-mmachine=ansi}''
  43. or ``\.{-mmachine=sun}''.\cr 
  44. MY\_BANNER&A possible local addition to the start-up banner, such as
  45. ``\.{-mMY\_BANNER=(Princeton)}''.\cr 
  46. SYS\_NAME&System name, usually used to customize the ANSI version, as in
  47. ``\.{-mSYS\_NAME=CRAY}''.\cr 
  48. TIMING\_WIDTH&Number of decimal places in the seconds field for timing
  49. statistics. For example, on the CRAY you might say
  50. ``\.{-mTIMING\_WIDTH=2}''.\cr 
  51. }}$$
  52. For the flags such as |SYS_NAME| that require string arguments, quotes are
  53. optional if the argument contains no embedded blanks.
  54. \endcomment
  55.  
  56. @ We can automatically generate the relevant lower-case machine flags from the
  57. value in \.{.fweb}.
  58.  
  59. @#ifdef ANSI
  60.     @m ANSI 1
  61. @#else
  62.     @m ANSI 0
  63. @#endif
  64.  
  65. @#ifdef APOLLO
  66.     @m APOLLO 1
  67. @#else
  68.     @m APOLLO 0
  69. @#endif
  70.  
  71. @#ifdef BSD
  72.     @m BSD 1
  73. @#else
  74.     @m BSD 0
  75. @#endif
  76.  
  77. @#ifdef CONFIG
  78.     @m CONFIG 1
  79. @#else
  80.     @m CONFIG 0
  81. @#endif
  82.  
  83. @#ifdef DSU
  84.     @m DSU 1
  85. @#else
  86.     @m DSU 0
  87. @#endif
  88.  
  89. @#ifdef IBMPC
  90.     @m IBMPC 1
  91. @#else
  92.     @m IBMPC 0
  93. @#endif
  94.  
  95. @#ifdef MAC
  96.     @m MAC 1
  97. @#else
  98.     @m MAC 0
  99. @#endif
  100.  
  101. @#ifdef MISC
  102.     @m MISC 1
  103. @#else
  104.     @m MISC 0
  105. @#endif
  106.  
  107. @#ifdef MVS
  108.     @m MVS 1
  109. @#else
  110.     @m MVS 0
  111. @#endif
  112.  
  113. @#ifdef SGI
  114.     @m SGI 1
  115. @#else
  116.     @m SGI 0
  117. @#endif
  118.  
  119. @#ifdef SUN
  120.     @m SUN 1
  121.  
  122.     @#ifdef GCC
  123.         @m SUN_GCC 1
  124.         @m SUN_CC 0
  125.     @#else
  126.         @m SUN_GCC 0
  127.         @m SUN_CC 1
  128.     @#endif
  129. @#else
  130.     @m SUN 0
  131.     @m SUN_GCC 0
  132.     @m SUN_CC 0
  133. @#endif
  134.  
  135. @#ifdef VAX
  136.     @m VAX 1
  137. @#else
  138.     @m VAX 0
  139. @#endif
  140.  
  141.  
  142. @* TEMPLATE DEFINITIONS.  First, we have a macro definition that generates
  143. the definition, conditionally commented out.  A similar definition handles
  144. file includes. The |SYS_PATH| macro is used for such things as
  145. \.{sys/types.h} that have slashes in them.
  146.  
  147. @m DEFN(when,text) $P define text $EVAL(when)
  148. @m DEFN0(when,txt) DEFN1(when,txt)
  149. @m DEFN1(when,txt) $IF(when,txt,$COMMENT(#txt))
  150.  
  151. @m AUTOCONFIG(name) 
  152.    AU0("(The flag |",#name,"| is set automatically in config.h by ./configure.)")
  153. @m AU0(s1,s2,s3) AU1(s1 s2 s3)
  154. @m AU1(s) $COMMENT(s)
  155.  
  156. @m INCLUDE(when,file) DEFN0(when,_P include <file.h>)
  157. @m INCLUDE_LOCAL(when,file) DEFN0(when,_P include #file)
  158.  
  159. @#if IBMPC
  160.     @m SYS_PATH(name) $TRANSLIT(#name,"/","\\")
  161. @#else
  162.     @m SYS_PATH(name) #!name
  163. @#endif /* |IBMPC| */
  164.  
  165.  
  166. @* EXECUTABLE STATEMENTS. Finally, here are the statements that are
  167. actually written into \.{custom.h} or \.{custom.h.in}.
  168.  
  169. @A
  170. /* --- BOOTSTRAPPING --- */
  171.  
  172. /* To bootstrap yourself onto a new system, you should modify this file
  173. appropriately.  In most cases, you set a flag by saying ``#define
  174. FLAG''---i.e., you make a null definition.  Don't set these flags to~0
  175. or~1.  However, in a few cases the macros are not flags and must be given
  176. the appropriate definition. */
  177.  
  178. /* --- MACHINE COMPILER FLAG --- */
  179.  
  180. /* This must be in lower case.  Presently these are drawn from the list
  181. {ansi, bsd, dsu, ibmpc, mac, misc, mvs, sgi, sun, vax}.  These
  182. flags may be used in #define statements within the source code to tailor
  183. things to a particular compiler or operating system.  If you use
  184. ./configure to generate custom.h, there will be no definition following
  185. this comment. */ 
  186. @#if !CONFIG 
  187. @#if ANSI
  188.     #ifndef ansi
  189.     #define ansi
  190.     #endif
  191. @#endif@%
  192. @#if APOLLO
  193.     #ifndef apollo
  194.     #define apollo
  195.     #endif // |apollo|
  196. @#endif@%
  197. @#if BSD
  198.     #ifndef bsd
  199.     #define bsd
  200.     #endif // |bsd|
  201. @#endif@%
  202. @#if DSU
  203.     #ifndef dsu
  204.     #define dsu
  205.     #endif // |dsu|
  206. @#endif@%
  207. @#if IBMPC
  208.     #ifndef ibmpc
  209.     #define ibmpc
  210.     #endif // |ibmpc|
  211. @#endif@%
  212. @#if MAC
  213.     #ifndef mac
  214.     #define mac
  215.     #endif // |mac|
  216. @#endif@%
  217. @#if MISC
  218.     #ifndef misc
  219.     #define misc
  220.     #endif // |misc|
  221. @#endif@%
  222. @#if MVS
  223.     #ifndef mvs
  224.     #define mvs
  225.     #endif // |mvs|
  226. @#endif@%
  227. @#if SGI
  228.     #ifndef sgi
  229.     #define sgi
  230.     #endif // |sgi|
  231. @#endif@%
  232. @#if SUN
  233.     #ifndef sun
  234.     #define sun
  235.     #endif // |sun|
  236. @#endif@%
  237. @#if VAX
  238.     #ifndef vax
  239.     #define vax
  240.     #endif // |vax|
  241. @#endif@%
  242. @#endif@%
  243.  
  244. @ The \FWEB\ variable |SYS_NAME| is usually used to customize the ANSI
  245. version. If it's not defined while tangling \.{custom.web}, it's given a
  246. default value. Things are set up so you can override by defining
  247. |sys_name| from the compiler's line while compiling \.{common.c}.
  248.  
  249. @m S(type) `_P`##define THE_SYSTEM@= @>$STRING(type) /* (Without the verbatim
  250.     command, the space disappears under expansion, which Microsoft doesn't
  251.     like.) */ 
  252.  
  253. @A
  254. /* --- FWEB SYSTEM NAME --- */
  255.  
  256. /* This is a string such as ``IBM-PC/DOS'' or ``VAX/VMS''. It is printed
  257. when FWEB starts up. */
  258.  
  259. @#ifdef SYS_NAME
  260.     S(SYS_NAME)
  261. @#else@%
  262. @#if CONFIG
  263.     S("UNIX")
  264. @#elif ANSI
  265.     S("ANSI/UNIX") 
  266. @#elif BSD
  267.     S("BSD")
  268. @#elif DSU
  269.     S("DECstation/ULTRIX")
  270. @#elif IBMPC
  271.     S("IBM-PC/MSDOS")
  272. @#elif MAC
  273.     S("Mac/SHELL")
  274. @#elif MISC
  275.     S("Vanilla")
  276. @#elif MVS
  277.     S("IBM/MVS")
  278. @#elif SGI
  279.     S("Iris")
  280. @#elif SUN
  281.     S("SunOS/UNIX")
  282. @#elif VAX
  283.     S("VAX/VMS")
  284. @#else
  285.     S("Unknown")
  286. @#endif@%
  287. @#endif@% /* NO |SYS_NAME|. */
  288.  
  289. /* --- An optional local banner, printed after the system name above. --- */
  290.  
  291. #define LOCAL_BANNER ""
  292.  
  293. @* Errors.  We attempt to use the \.{\#error} command to warn the user
  294. about inconsistencies.
  295. @A
  296. /* Does your compiler understand the ANSI preprocessor command \#error?
  297. If it does, define |HAVE_ERROR|.  (I haven't figured out a general
  298. autoconf test yet; it seems to be impossible in principle.) */
  299.  
  300. DEFN(CONFIG || ANSI || IBMPC || MVS || SUN_GCC ||VAX,HAVE_ERROR)@;
  301.  
  302. @* ASCII translation.  For efficiency, translations to and from the
  303. character set of the external world to \FWEB's internal |ASCII| aren't
  304. carried out on |ASCII| machines.
  305. @A
  306. /* Do we bother with translations to the internal |ASCII| representation?
  307. If so, define |TRANSLATE_ASCII|.  Don't bother on |ASCII| machines. */
  308.  
  309. DEFN(MVS,TRANSLATE_ASCII)@;
  310.  
  311. /* For \It{debugging} of target machines whose character set differs from
  312. the one on which you're working, define |DEBUG_XCHR|.  \It{Usually, this
  313. flag should not be defined.}  When it is defined, the |TRANSLATE_ASCII|
  314. flag is automatically turned on, and the value of the style-file field
  315. `xchr' is relevant. \It{Don't use this flag unless you're a system
  316. developer!!!} */
  317.  
  318. DEFN(0,DEBUG_XCHR)@;
  319.  
  320. @* Path format.  @A /* Does the operating system have a Unix-like path?
  321. That is, does it have the form ``/u/krommes'' rather than the VMS form
  322. ``ux3:[krommes]''?  If so, define |UNIX_PATH|. */
  323.  
  324. DEFN(!VAX,UNIX_PATH)@;
  325.  
  326. @* Environment variables.
  327. @A
  328. /* If the |getenv| call to obtain an environment variable is supported
  329. (it usually is) define |HAVE_GETENV|. */
  330. @#if CONFIG
  331.     AUTOCONFIG(HAVE_GETENV)
  332. @#else@%
  333.     DEFN(!(MAC || MVS), HAVE_GETENV)@;
  334. @#endif@%
  335.  
  336. @* File names and extensions.
  337.  
  338. @m NFN(type) `_P`##define NULL_FILE_NAME@= @>$STRING(type) 
  339.     /* (Without the verbatim
  340.     command, the space disappears under expansion, which Microsoft doesn't
  341.     like.) */ 
  342.  
  343. @A
  344. /* --- FILE NAMES and EXTENSIONS --- */
  345.  
  346. /* Name of the null file.  This macro merely defines the default value of
  347. the style-file parameter `null_file', so it's not essential to add any more
  348. machines here. */
  349.  
  350. @#ifdef NULL_NAME
  351.     NFN(NULL_NAME)
  352. @#else@%
  353. @#if VAX
  354.     NFN("nl:")
  355. @#elif IBMPC
  356.     NFN("nul")
  357. @#elif MVS
  358.     NFN("'NULLFILE'")
  359. @#else
  360.     NFN("/dev/null") // For Unix systems.
  361. @#endif@%
  362. @#endif@%
  363.  
  364. /* Name of \FWEB's initialization file.  Please see below, after the
  365. definition of |SMALL_MEMORY|. */
  366.  
  367. /* Name of \FWEB's default style file.  \It{Please don't change this unless
  368. you absolutely have to!  Use the `-z' option instead.} */
  369.  
  370. #define STYLE_FILE_NAME "fweb.sty"
  371.  
  372. /* Here are the default file extensions for each language.  These merely
  373. set default style-file parameters, so it's not essential that you change
  374. anything here.  See the parameters `suffix.C', `suffix.N', etc. */
  375.  
  376. #define C_EXT "c"
  377. #define V_EXT "mk"
  378. #define X_EXT "sty"
  379.  
  380. @#if CONFIG || ANSI || APOLLO || DSU || MISC || SGI || SUN
  381. /* Unix. */
  382.     #define Cpp_EXT "C" // Per \.{gcc}.
  383.     #define R_EXT "r"
  384.     #define R90_EXT "r90"
  385.     #define N_EXT "f"
  386.     #define N90_EXT "f90"
  387. @#else 
  388. /* Non-unix. */
  389.     #define Cpp_EXT "C"
  390.     #define R_EXT "rat"
  391.     #define R90_EXT "rat90"
  392.     #define N_EXT "for"
  393.     #define N90_EXT "for90"
  394. @#endif@%
  395.  
  396. @#if CONFIG
  397.     AUTOCONFIG(HAVE_TMPNAM)
  398.     AUTOCONFIG(HAVE_TEMPNAM)
  399. @#else
  400.     DEFN(1, HAVE_TMPNAM)@;
  401.     DEFN(0, HAVE_TEMPNAM)@;
  402. @#endif
  403.  
  404. @* Fancy continuations.  
  405. @A
  406. /* The |FANCY_SPLIT| flag is used for buffering the output lines of C~code.
  407. Define this if the C~compiler CAN'T continue an incomplete line with a
  408. backslash.  (ANSI compilers should be able to.)
  409. {\bf (This code may not be fully debugged yet!)} */
  410.  
  411. @#if CONFIG
  412.     AUTOCONFIG(FANCY_SPLIT)
  413. @#else
  414.     DEFN(SUN_CC || DSU || VAX,FANCY_SPLIT)@;
  415. @#endif
  416.  
  417. @* Including files.
  418. @A
  419. /* --- INCLUDING FILES --- */
  420.  
  421. /* The code is written in C, and various header files of the form
  422. ``<*.h>'' are included near the beginning of each source file.  The
  423. names of these files are standardized by ANSI.  Unfortunately, not everyone
  424. has gotten around to ANSI yet.  Therefore, here we include important files
  425. whose names may be nonstandard or whose functions may fluctuate. */
  426.  
  427. /* Does the ANSI <stdlib.h> exist?  If so, say so here.  This is supposed
  428. to contain prototypes for the following functions used by \FWEB: |abort|,
  429. |abs|, |atof|, |atoi|, |atol|, |calloc|, |exit|, |free|, |getenv|,
  430. |realloc|, |strtod|, |strtol|.  If it doesn't, either find the prototypes
  431. in another file and include it here, or actually give the prototypes here. */
  432.  
  433. @#if CONFIG
  434.     AUTOCONFIG(HAVE_STDLIB_H)
  435. @#else
  436. DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN || VAX,HAVE_STDLIB_H)@;
  437. @#endif
  438.  
  439. @#if CONFIG
  440.     AUTOCONFIG(HAVE_STDARG_H)
  441. @#else
  442. DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN || VAX,HAVE_STDARG_H)@;
  443. @#endif
  444.  
  445.  
  446. /* Does the ANSI <stddef.h> exist?  If so, include it here.  This is
  447. supposed to define the |NULL| pointer, and the type |size_t|.  Sometimes
  448. these are defined in other places as well. */
  449.  
  450. @#if CONFIG
  451.     AUTOCONFIG(HAVE_STDDEF_H)
  452. @#else
  453.     DEFN(ANSI || IBMPC || MISC || MVS || VAX,HAVE_STDDEF_H)@;
  454. @#endif
  455.  
  456. /* Other stuff handled by autoconf. */
  457. @#if CONFIG
  458.     AUTOCONFIG(HAVE_STRING_H)
  459. @#else
  460. DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN || VAX,HAVE_STRING_H)@;
  461. @#endif
  462.  
  463. @#if CONFIG
  464.     AUTOCONFIG(HAVE_MEMORY_H)
  465. @#else
  466.     DEFN(0,HAVE_MEMORY_H)@;
  467. @#endif
  468.  
  469. @#if CONFIG
  470.     AUTOCONFIG(HAVE_FLOAT_H)
  471. @#else
  472. DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN || VAX,HAVE_FLOAT_H)@;
  473. @#endif
  474.  
  475. /* Does (non-ANSI) <sys/types.h> exist?  You may find some useful stuff in
  476. here. But don't use it unless you have to. */
  477.  
  478. INCLUDE(!CONFIG && (APOLLO || DSU || SGI || SUN), SYS_PATH(sys/types))@;
  479.  
  480. /* Must we include an extra file for memory management?  E.g., for
  481. Microsoft, <malloc.h>; for Borland; <alloc.h>.  Not necessary for ANSI;
  482. it's in <stdlib.h>. */
  483.  
  484. INCLUDE(IBMPC,malloc)@;
  485.  
  486. /* Numerical limits.  We use the following ANSI macros: |INT_MAX|,
  487. |INT_MIN|, |LONG_MAX|, |LONG_MIN|, and |ULONG_MAX|, which are found in
  488. <limits.h>. If you can't find those macros, define the flag
  489. |HAVE_VALUES_H|, and possibly include another file with different names for
  490. the limits, such as <values.h> on the Sun.  The flag |HAVE_VALUES_H|
  491. assumes that the macros |MAXINT| and |MAXLONG| are defined.  If they are
  492. not, you must define them here. */
  493.  
  494. @#if CONFIG
  495.     AUTOCONFIG(HAVE_LIMITS_H)
  496.     AUTOCONFIG(HAVE_VALUES_H)
  497. @#else
  498. DEFN(ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN_GCC|| VAX,HAVE_LIMITS_H)@;
  499. DEFN(APOLLO || SUN_CC,HAVE_VALUES_H)@;
  500. @#endif
  501.  
  502. /* Please note that additional files are included automatically
  503. (essentially immediately after this file is read; see <includes.hweb>).
  504. These were considered to be standard, but that might be a mistake.  Those
  505. files are: <string.h>, <stdio.h>, <ctype.h>, <setjmp.h>, <time.h>.
  506. Remember that by convention these files should limit themselves to being
  507. included only once.  Therefore, if for some reason you need to include one
  508. of these somewhere in this file, you should be able to do it without
  509. difficulty; the later automatic include just won't be done if those files
  510. are following standard protocol. */
  511.  
  512. @#if CONFIG
  513.     AUTOCONFIG(ANSI_CTYPE_H)
  514. @#else
  515.     DEFN(ANSI || IBMPC || SUN_GCC,ANSI_CTYPE_H)@;
  516. @#endif
  517.  
  518. @* Variable-length argument lists.
  519. @A
  520. /* --- VARIABLE-LENGTH ARGUMENT LISTS --- */
  521.  
  522. /* For convenience, FWEB attempts to use functions with variable numbers of
  523. arguments.  We attempt to support two conventions: ANSI, and Sun's.  If
  524. this feature is supported, define the flag |VARIABLE_ARGUMENTS|, say
  525. whether |va_start| has one or two arguments, and include the associated
  526. header file (<stdarg.h> for ANSI). */
  527.  
  528. /* Does the compiler allow ANSI-style variable arguments? */
  529.  
  530. DEFN(CONFIG || ANSI || IBMPC || MISC || MVS || SUN || VAX, VARIABLE_ARGUMENTS)@;
  531.  
  532. /* Is |va_start| defined with one argument (Sun's convention) or two
  533. (ANSI)? */  
  534. @#if SUN_CC
  535.     #define NUM_VA_ARGS 1
  536. @#else
  537.     #define NUM_VA_ARGS 2
  538. @#endif
  539. @#if CONFIG
  540.     AUTOCONFIG(HAVE_STDARG_H)
  541. @#else
  542. DEFN(CONFIG || ANSI || DSU || IBMPC || MISC || MVS || SGI || SUN_GCC|| VAX,HAVE_STDARG_H)@;
  543. @#endif
  544.  
  545. @* Additional prototypes.
  546. @A
  547. /* --- ADDITIONAL PROTOTYPES --- */
  548.  
  549. /* You may wish to collect any additional prototypes that are required and
  550. put them into your own header file that you include here. */
  551.  
  552. /* If the flag |HAVE_STD_PROTOTYPES| is false, it causes the file
  553. "stdlib0.h" to be loaded.  This contains ANSI prototypes that for some
  554. reason aren't provided with the gcc environment on the Sun. */
  555. @#if CONFIG
  556.     AUTOCONFIG(HAVE_STD_PROTOTYPES)
  557. @#else
  558.     DEFN(!SUN_GCC,HAVE_STD_PROTOTYPES)@; 
  559. @#endif
  560.  
  561. @* Function prototyping, etc.  
  562. @A 
  563. /* Define the flag |OLD_PROTOTYPES| for compilers that don't support the
  564. new (ANSI) style of function declaration and prototyping.  The new style is
  565. |fcn(int i,char *s){}|; the old style is |fcn(i,s) int i; char *s; {}|. */
  566.  
  567. @#if CONFIG
  568.     AUTOCONFIG(OLD_PROTOTYPES)
  569. @#else
  570.     DEFN(SUN_CC || DSU || MAC || SGI || MISC || VAX, OLD_PROTOTYPES)@;
  571. @#endif
  572.  
  573. /* ANSI also introduces the type |void|.  If your compiler doesn't
  574. understand the constructions |void *| and |void fcn()|, define |NO_VOID|. */
  575.  
  576. @#if CONFIG
  577.     AUTOCONFIG(NO_VOID)
  578. @#else
  579.     DEFN(DSU || MAC || SGI || SUN_CC, NO_VOID)@;
  580. @#endif
  581.  
  582. @* Special types.
  583. @A
  584. /* --- SPECIAL TYPES --- */
  585.  
  586. /* |const| seems to be an annoyance; not all compilers treat it the same
  587. way.  We really only want it for debugging, anyway, so we mostly just
  588. remove it.  It's kept when compiling on the Sun with gcc, because it
  589. gives the developer more checks on the code.  If you want to keep it,
  590. define |KEEP_CONST|. */
  591.  
  592. DEFN(CONFIG || SUN_GCC,KEEP_CONST)@;
  593.  
  594. /* For personal computers, the kind of pointer is an issue.  They must be
  595. |huge|.  If your compiler understands |huge|, define |HUGE_POINTERS|. */
  596.  
  597. DEFN(IBMPC,HUGE_POINTERS)@;
  598.  
  599. @* Special functions.
  600. @A
  601. /* --- SPECIAL FUNCTIONS --- */
  602.  
  603. /* The ANSI |sprintf| function returns the number of characters written.
  604. If this is the case on your system, define |ANSI_SPRINTF|.  (It's always
  605. safe to not define it.) */
  606.  
  607. @#if CONFIG
  608.     AUTOCONFIG(ANSI_SPRINTF)
  609. @#else
  610.     DEFN((ANSI || IBMPC || MVS || VAX),ANSI_SPRINTF)@;
  611. @#endif
  612.  
  613. /* The ANSI |sscanf| does some cute things with scansets, but it doesn't
  614. always work. */
  615. @#if CONFIG
  616.     AUTOCONFIG(ANSI_SSCANF)
  617. @#else
  618.     DEFN(ANSI || IBMPC || SUN_GCC, ANSI_SSCANF)@;
  619. @#endif
  620.  
  621. /* The ANSI |system| function is supposed to take |NULL| as an argument,
  622. which means check if a command processor exists.  If this works properly,
  623. defined |ANSI_SYSTEM|.  (It doesn't work on the Sun.) */
  624.  
  625. DEFN(ANSI || IBMPC, ANSI_SYSTEM)@;
  626.  
  627. @* Annoying warnings.  
  628. @A
  629. /* --- ANNOYING WARNINGS --- */
  630.  
  631. /* Sometimes the compiler can't understand that the
  632. control flow can never get to the bottom of a function. To avoid warning
  633. complaints, we have the following: */
  634.  
  635. @#if SUN_CC || DSU || SGI
  636.     #define DUMMY_RETURN(value) 
  637. @#else
  638.     #define DUMMY_RETURN(value) return value
  639. @#endif
  640.  
  641. @* Functions with unusual names.
  642. The Aztec environment handled newlines in a non-standard way, and had
  643. some other peculiarities.
  644.  
  645. @f lmalloc malloc
  646.  
  647. @A
  648. /* --- UNUSUAL NAMES --- */
  649.  
  650. /* Put here any definitions that override standard names.  For example, for
  651. some ancient on the MAC one had to say ``#define getc agetc''. */
  652.  
  653. @#if MAC /* \.{Machine-dependent}: Non-Unix treatment of newlines, and some
  654.         other garbage. */
  655.     #define index indexx
  656.     #define getc agetc 
  657.     #define putc aputc
  658.     #define abs(i) (i > 0 ? i : (-i)) // Maybe in some other header file?
  659. @#else
  660.     /* Nothing to be done. */
  661. @#endif@%
  662.  
  663. @* Directory specifications.
  664. @A
  665. /* --- DIRECTORY SPECIFICATIONS --- */
  666.  
  667. /* Directory specifications are delimited in different ways under the various
  668. operating systems. Unix: '/'; IBM-PC: '\\'; VAX/VMS: ']'. */
  669.  
  670. @#ifdef PREFIX_END_CHR
  671.     #define PREFIX_END_CHAR PREFIX_END_CHR
  672. @#else@%
  673. @#if VAX
  674.     #define PREFIX_END_CHAR ']' // The VAX has a peculiar format.
  675. @#elif IBMPC
  676.     #define PREFIX_END_CHAR '\\' // IBM is perverse.
  677. @#else@%
  678.     #define PREFIX_END_CHAR '/' // The Unix convention.
  679. @#endif@%
  680. @#endif@%
  681.  
  682. @* Timing.
  683. @A
  684. /* --- TIMING --- */
  685.  
  686. /* First of all, we have a flag to say whether timing information is
  687. printed at the end of the run.  (If you can't figure out the timing
  688. routines for your machine or don't want a timing information line at the
  689. end of your terminal output, don't define this.)  Beginning with fweb-1.53,
  690. timing is turned off by default. */
  691.  
  692. DEFN(0 && !(MVS),TIMING)@;
  693.  
  694. /* --- Number of decimal places  for timing information in seconds.  (Use
  695. at least 2 for supercomputers.) --- */
  696.  
  697. #define TIMING_WIDTH 1
  698.  
  699. /* There's supposed to be a function |clock()| that returns the cpu time,
  700. in units of |CLOCKS_PER_SEC|.  The type of |clock| is |clock_t|.  If that
  701. is defined, define the flag |CLOCK_T_DEFINED|; otherwise, say |typedef ...
  702. clock_t| here. */
  703.  
  704. @#if CONFIG
  705.     AUTOCONFIG(CLOCK_T_DEFINED)
  706. @#else
  707.     DEFN(!(APOLLO || SGI), CLOCK_T_DEFINED)@;
  708. @#endif
  709.  
  710. /* Some systems don't define |CLOCKS_PER_SEC|.  If not, we try |CLK_TCK|.
  711. If that's not defined, it defaults to 1000000.  If that's not appropriate,
  712. define |CLOCKS_PER_SEC| here. */
  713.  
  714. /*
  715. #define CLOCKS_PER_SEC 1000000
  716. */
  717.  
  718. /* Are there system routines that return wall-clock time in sub-second units? 
  719. First, look for |gettimeofday| ($\mu$sec timing). */
  720. @#if CONFIG
  721.     AUTOCONFIG(HAVE_GETTIMEOFDAY)
  722. @#else
  723.     DEFN(SUN,HAVE_GETTIMEOFDAY)@;
  724. @#endif
  725.  
  726. /* Otherwise, does the file sys/timeb.h exist that along with |ftime| gives
  727. millisecond timing for wall-clock time?  We check for the header file, not
  728. |ftime| itself, since |ftime| may be in a Berkeley compatibility library,
  729. not in libc. */
  730.  
  731. @#if CONFIG
  732.     AUTOCONFIG(HAVE_SYS_TIMEB_H)
  733. @#else
  734.     DEFN((APOLLO || DSU || IBMPC),HAVE_SYS_TIMEB_H)@;
  735. @#endif
  736.  
  737. /* Do we use our own version of |difftime()|, which computes the difference
  738. of two wall clock times?  If so, define |NEW_DIFFTIME|.  This flag should
  739. always be defined if |HAVE_SYS_TIMEB_H| is defined above.  */
  740.  
  741. @#if CONFIG
  742.     /* |NEW_DIFFTIME| is computed from flags set by ./configure. */
  743. @#else
  744.     DEFN(APOLLO || DSU || IBMPC || MAC || MISC || SGI || SUN, NEW_DIFFTIME)@;
  745. @#endif
  746.  
  747. @* Squeezing it down.
  748. @A
  749. /* --- MAKING IT FIT --- */
  750.  
  751. /* Sometimes the compiler can't handle functions or switches that are too
  752. large.  In that case, define |FCN_CALLS|.  That converts certain in-line
  753. code (such as in the syntax production analyzer) into function calls (at
  754. the price of slowing things down a bit). */
  755.  
  756. @#ifdef F_CALLS
  757.     #define FCN_CALLS F_CALLS
  758. @#else
  759.     DEFN(IBMPC || MAC, FCN_CALLS)@;
  760. @#endif
  761.  
  762. /* The personal computers are starved for memory.  For those machines, we
  763. specify smaller default values for the lengths of dynamic arrays; define
  764. |SMALL_MEMORY|.  (You can always use the `-y' option to override these
  765. defaults.) */ 
  766.  
  767. @#ifdef SMALL_MEM
  768.     #define SMALL_MEMORY SMALL_MEM
  769. @#else
  770.     DEFN(IBMPC || MAC, SMALL_MEMORY)@;
  771. @#endif
  772.  
  773. /* Name of \FWEB's default initialization file.  Please don't change these
  774. conventions unless you absolutely have to!!!  Also, note that these
  775. definitions are overridden by the environment variable |FWEB_INI|, if it is
  776. defined. */
  777.  
  778. #ifndef SMALL_MEMORY
  779.     #define SMALL_MEMORY 0
  780. #endif
  781.  
  782. #if SMALL_MEMORY
  783.     #define FWEB_INI "fweb.ini"
  784. #else
  785.     #define FWEB_INI ".fweb"
  786. #endif
  787.  
  788. @* Allocating and printing memory.
  789.  
  790. @A
  791. /* --- MEMORY ALLOCATIONS --- */
  792.  
  793. /* The ANSI |calloc| routine takes two arguments:  |void
  794. *calloc(size_t,size_t)|. If the system doesn't have a standard |calloc|
  795. routine, or if the name isn't standard, you must define an UPPERCASE macro
  796. that does the same thing.  (The name isn't standard on personal computers
  797. because one is dealing with |huge| allocations.)  If you define
  798. |NON_ANSI_CALLOC|, you must define |CALLOC|, |REALLOC|, and |FREE|.  E.g., the
  799. relevant definitions for Borland are
  800. \begintt
  801. #define CALLOC farcalloc
  802. #define REALLOC(oldblock,nbytes) \
  803.  farrealloc((void far *)(oldblock),(unsigned long)(nbytes))
  804. #define FREE(block) farfree((void far *)(block))
  805. \endtt
  806. */ 
  807.  
  808. DEFN(IBMPC || MAC,NON_ANSI_CALLOC)@;
  809.  
  810. /* |IBMPC| */
  811. @#if IBMPC
  812.     #define CALLOC halloc
  813.     #define REALLOC hrealloc
  814.     #define FREE hfree
  815. @#elif MAC
  816.     #define CALLOC(nunits,nsize) lmalloc(nunits*nsize)
  817.     #define REALLOC(oldptr, new_size, old_size) realloc(old_ptr, new_size)
  818.     #define FREE free
  819. @#endif
  820.  
  821. /* Do we supply below a routine that obtains the available memory, such 
  822. as Borland's farcoreleft()? */
  823.  
  824. DEFN(IBMPC,PRINT_AVAILABLE_MEMORY)
  825.  
  826. /* The function call that obtains the memory is called |CORE_LEFT|.  This
  827. function is assumed to return an |unsigned long int|.  For Microsoft, we had
  828. to write our own routine |_hmemavl|; see below.  For Borland, the routine
  829. should be called |farcoreleft|.  For the other machines, we don't have
  830. anything as yet. */ 
  831.  
  832. @#if IBMPC
  833.     #define CORE_LEFT _hmemavl()
  834. @#endif
  835.  
  836.  
  837. @* ADDITIONAL FUNCTIONS.  
  838.  
  839. @A
  840. /* The following flag is defined only by \common.web}. */
  841. #ifdef COMMON_FCNS_
  842. #if(part==0 || part==1)
  843.  
  844. /* Give here the C code for any additional functions that are
  845. compiler-specific or missing from your implementation, such as maybe
  846. |strtod|.  Note that these are bracketed with the flag COMMON_FCNS_ so they
  847. are compiled into just one module, namely common.c. You must
  848. always supply some version of the debugging routine |trap|, which must
  849. return~0 as a minimum. */
  850. @#if IBMPC /* \.{Machine-dependent}: Custom memory routines required. */
  851.     @<Finding out about memory@>@;
  852. @#endif
  853. @<Additional compiler-specific functions@>@;
  854. #endif /* |part == 1| */
  855.  
  856. #endif // |COMMON_FCNS_|
  857.  
  858. @
  859. @<Finding out about memory@>=
  860.  
  861. /* For Microsoft, we must write our own routine to find out about memory,
  862. since no heap management is done for the huge model. */
  863.  
  864. #ifdef mcc /* This flag is defined by the Microsoft compiler. */
  865.  
  866. #include <dos.h>
  867. #define DOS_GET_MEM 0x48
  868.  
  869. unsigned long _hmemavl(void)
  870. {
  871. union REGS inregs,outregs;
  872.  
  873. inregs.h.ah = DOS_GET_MEM;
  874. inregs.x.bx = 0xFFFF; /* Force the request to fail by giving a number
  875.                 that's too big. */
  876.  
  877. intdos(&inregs,&outregs);  /* Make DOS system call. */
  878.  
  879. /* When the allocation fails, \.{BX} will return the size of the largest
  880. block of memory available in paragraphs. */
  881. return 16*(unsigned long)outregs.x.bx;
  882. }
  883. #endif /* mcc */
  884.  
  885. @ Here we insert any extra functions that are compiler-specific.  
  886.  
  887. @<Additional compiler-specific...@>=
  888.  
  889. @#if MAC /* \.{Machine-dependent}: If you want to use the \FWEB\
  890.         breakpoint/debugging system. */
  891. /* Required routines for the MAC. */
  892. SRTN trap(m,name)
  893.     int m;
  894.     char name[];
  895. {
  896. #if(0)
  897. printf("Mod %d: \"%s\"\n",m,name); /* For debugging. */
  898. #endif
  899. }
  900.  
  901. double pow()
  902. {
  903. puts("! Error: make the linker find pow().");
  904. return 0.0;
  905. }
  906.  
  907. double strtod()
  908. {
  909. puts("! Error: Need replacement routine for strtod");
  910. return 0.0;
  911. }
  912.  
  913. long strtol()
  914. {
  915. puts("! Error: Need replacement function for strtol");
  916. return 0;
  917. }
  918. @#else
  919. /* The default |trap| function for debugging. */
  920. int trap(void)
  921. {return 0;}
  922. @#endif
  923.  
  924.