home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / language / gofer / Sources / h / prelude < prev    next >
Encoding:
Text File  |  1993-03-04  |  11.9 KB  |  337 lines

  1. /* --------------------------------------------------------------------------
  2.  * prelude.h:   Copyright (c) Mark P Jones 1991-1993.   All rights reserved.
  3.  *              See goferite.h for details and conditions of use etc...
  4.  *              Gofer version 2.28 January 1993
  5.  *
  6.  * Basic data type definitions, prototypes and standard macros including
  7.  * machine dependent variations...
  8.  * ------------------------------------------------------------------------*/
  9.  
  10. #define const          /* const is more trouble than it's worth,...       */
  11. #include <stdio.h>
  12.  
  13. /*---------------------------------------------------------------------------
  14.  * To select a particular machine/compiler, just place a 1 in the appropriate
  15.  * position in the following list and ensure that 0 appears in all other
  16.  * positions:
  17.  *
  18.  * The letters UN in the comment field indicate that I have not personally
  19.  * been able to test this configuration yet and I have not heard from anybody
  20.  * else that has tried it.  If you run Gofer on one of these systems and it
  21.  * works (or needs patches) please let me know so that I can fix it and
  22.  * update the source.
  23.  *-------------------------------------------------------------------------*/
  24.  
  25. #define TURBOC   0      /* For IBM PC, using Turbo C 1.5           */
  26. #define BCC     0      /* For IBM PC, using Borland C++ 3.1           */
  27. #define SUNOS    0      /* For Sun 3/Sun 4 running SunOs 4.x           */
  28. #define NEXTSTEP 0      /* For NeXTstep 3.0 using NeXT cc           */
  29. #define NEXTGCC  0    /* For NeXTstep with gcc 2.x               */
  30. #define MINIX68K 0    /* For Minix68k with gcc            UN */
  31. #define AMIGA    0    /* For Amiga using gcc 2.2.2            UN */
  32. #define HPUX     0      /* For HPUX using gcc                UN */
  33. #define LINUX    0      /* For Linux using gcc                UN */
  34. #define DJGPP    0    /* For DJGPP version 1.09 (gcc2.2.2) and DOS 5.0   */
  35. #define RISCOS   1    /* For Acorn DesktopC and RISCOS2 or 3           */
  36. #define ALPHA     0    /* For DEC Alpha with OSF/1 (32 bit ints, no gofc) */
  37. #define OS2      0    /* For IBM OS/2 2.0 using EMX GCC           */
  38. #define SVR4     0    /* For SVR4 using GCC2.2               */
  39. #define ULTRIX   0      /* For DEC Ultrix 4.x using GCC2.3.3           */
  40. #define AIX     0    /* For IBM AIX on RS/6000 using GCC           */
  41.  
  42. /*---------------------------------------------------------------------------
  43.  * To add a new machine/compiler, add a new macro line above, add the new
  44.  * to the appropriate flags below and add a `machine specific' section in the
  45.  * following section of this file.  Please send me details of any new machines
  46.  * or compilers that you try so that I can pass them onto others!
  47.  *
  48.  *   UNIX          if the machine runs fairly standard Unix
  49.  *   SMALL_GOFER   for 16 bit operation on a limited memory PC
  50.  *   REGULAR_GOFER for 32 bit operation using largish default table sizes
  51.  *   LARGE_GOFER   for 32 bit operation using larger default table sizes
  52.  *   JMPBUF_ARRAY  if jmpbufs can be treated like arrays.
  53.  *   DOS_IO        to use DOS style IO for terminal control
  54.  *   TERMIO_IO     to use Unix termio for terminal control
  55.  *   SGTTY_IO      to use Unix sgtty for terminal control
  56.  *   BREAK_FLOATS  to use two integers to store a float (or double)
  57.  *           if SMALL_GOFER, then you *must* use BREAK_FLOATS == 1
  58.  *           (assumes sizeof(int)==2, sizeof(float)==4).
  59.  *           Otherwise, assuming sizeof(int)==sizeof(float)==4,
  60.  *                 BREAK_FLOATS == 0 will give you floats  for floating pt,
  61.  *           BREAK_FLOATS == 1 will give you doubles for floating pt.
  62.  *   HAS_FLOATS       to indicate support for floating point
  63.  *-------------------------------------------------------------------------*/
  64.  
  65. #define UNIX          (SUNOS  | NEXTSTEP | HPUX | NEXTGCC | LINUX | AMIGA | \
  66.                MINIX68K |ALPHA | OS2 | SVR4 | ULTRIX | AIX)
  67. #define SMALL_GOFER   (TURBOC | BCC)
  68. #define REGULAR_GOFER (RISCOS | DJGPP)
  69. #define LARGE_GOFER   (UNIX   | ALPHA)
  70. #define JMPBUF_ARRAY  (UNIX   | DJGPP | RISCOS)
  71. #define DOS_IO        (TURBOC | BCC | DJGPP)
  72. #define TERMIO_IO     (LINUX  | HPUX | OS2 | SVR4)
  73. #define SGTTY_IO      (SUNOS  | NEXTSTEP | NEXTGCC | AMIGA | MINIX68K | \
  74.                        ALPHA  | ULTRIX | AIX)
  75. #define BREAK_FLOATS  (TURBOC | BCC)
  76. #define HAS_FLOATS    (REGULAR_GOFER | LARGE_GOFER | BREAK_FLOATS)
  77.  
  78. /*---------------------------------------------------------------------------
  79.  * The following flags should be set automatically according to builtin
  80.  * compiler flags, but you might want to set them manually to avoid default
  81.  * behaviour in some situations:
  82.  *-------------------------------------------------------------------------*/
  83.  
  84. #ifdef  __GNUC__            /* look for GCC 2.x extensions       */
  85. #if     __GNUC__ >= 2 && !NEXTSTEP    /* NeXT cc lies and says it's 2.x  */
  86. #define GCC_THREADED 1
  87.  
  88. /* WARNING: if you use the following optimisations to assign registers for
  89.  * particular global variables, you should be very careful to make sure that
  90.  * storage(RESET) is called after a longjump (usually resulting from an error
  91.  * condition) and before you try to access the heap.  The current version of
  92.  * main deals with this using everybody(RESET) at the head of the main read,
  93.  * eval, print loop
  94.  */
  95.  
  96. #ifdef  m68k                /* global registers on an m68k       */
  97. #define GLOBALcar    asm("a4")
  98. #define GLOBALcdr    asm("a5")
  99. #define GLOBALsp    asm("a3")
  100. #endif
  101.  
  102. #ifdef  sparc                /* global registers on a sparc       */
  103. /* sadly, although the gcc documentation suggests that the following reg   */
  104. /* assignments should be ok, experience shows (at least on Suns) that they */
  105. /* are not -- it seems that atof() and friends spoil things.           */
  106. /*#define GLOBALcar    asm("g5")*/
  107. /*#define GLOBALcdr    asm("g6")*/
  108. /*#define GLOBALsp    asm("g7")*/
  109. #endif
  110.  
  111. #endif
  112. #endif
  113.  
  114. #ifndef GCC_THREADED
  115. #define GCC_THREADED 0
  116. #endif
  117.  
  118. /*---------------------------------------------------------------------------
  119.  * Machine specific sections:
  120.  * Include any machine specific declarations and define macros:
  121.  *   local              prefix for locally defined functions
  122.  *   far                prefix for far pointers
  123.  *   allowBreak()       call to allow user to interrupt computation
  124.  *   FOPEN_WRITE        fopen *text* file for writing
  125.  *   FOPEN_APPEND       fopen *text* file for append
  126.  *-------------------------------------------------------------------------*/
  127.  
  128. #ifdef __STDC__           /* To enable use of prototypes whenever possible */
  129. #define Args(x) x
  130. #else
  131. #if (TURBOC | BCC)        /* K&R 1 does not permit `defined(__STDC__)' ... */
  132. #define Args(x) x
  133. #else
  134. #define Args(x) ()
  135. #endif
  136. #endif
  137.  
  138. #if     (TURBOC | BCC)
  139. #include <alloc.h>
  140. #define local           near pascal
  141. extern  int  kbhit       Args((void));
  142. #define allowBreak()       kbhit()
  143. #define FOPEN_WRITE       "wt"
  144. #define FOPEN_APPEND       "at"
  145. #define farCalloc(n,s)       farcalloc((unsigned long)n,(unsigned long)s)
  146. #define sigProto(nm)       int nm(void)
  147. #define sigRaise(nm)       nm()
  148. #define sigHandler(nm)       int nm()
  149. #define sigResume       return 1
  150. #endif
  151.  
  152. #if     SUNOS
  153. #include <malloc.h>
  154. #define far
  155. #define farCalloc(n,s)       (Void *)valloc(((unsigned)n)*((unsigned)s))
  156. #endif
  157.  
  158. #if     (NEXTSTEP | NEXTGCC | AMIGA | MINIX68K | ULTRIX)
  159. #include <stdlib.h>
  160. #define far
  161. #define farCalloc(n,s)       (Void *)valloc(((unsigned)n)*((unsigned)s))
  162. #endif
  163.  
  164. #if     (HPUX | DJGPP | LINUX | ALPHA | OS2 | SVR4 | AIX)
  165. #include <stdlib.h>
  166. #define far
  167. #endif
  168.  
  169. #if    RISCOS
  170. #include <string.h>
  171. #include <stdlib.h>
  172. #include <signal.h>
  173. #define  far
  174. #define  isascii(c)    (((unsigned)(c))<128)
  175. #define  Main        int
  176. #define  MainDone    return 0;/*NOTUSED*/
  177. extern   int access    Args((char *, int));
  178. extern   int namecmp    Args((char *, char *));
  179. #ifndef GOFC_INCLUDE
  180. #define GOFC_INCLUDE "gofc.h"
  181. #endif
  182. #endif
  183.  
  184. #ifndef USE_READLINE
  185. #define USE_READLINE  0
  186. #endif
  187. #ifndef allowBreak
  188. #define allowBreak()
  189. #endif
  190. #ifndef local
  191. #define local
  192. #endif
  193. #ifndef farCalloc
  194. #define farCalloc(n,s)       (Void *)calloc(((unsigned)n),((unsigned)s))
  195. #endif
  196. #ifndef FOPEN_WRITE
  197. #define FOPEN_WRITE       "w"
  198. #endif
  199. #ifndef FOPEN_APPEND
  200. #define FOPEN_APPEND       "a"
  201. #endif
  202. #ifndef sigProto
  203. #define sigProto(nm)       Void nm Args((int))
  204. #define sigRaise(nm)       nm(1)
  205. #define sigHandler(nm)       Void nm(sig_arg) int sig_arg;
  206. #define sigResume       return
  207. #endif
  208. #ifndef Main            /* to cope with systems that don't like       */
  209. #define Main           Void /* main to be declared as returning Void   */
  210. #endif
  211. #ifndef MainDone
  212. #define MainDone
  213. #endif
  214.  
  215. #if (UNIX | DJGPP | RISCOS)
  216. #define ctrlbrk(bh)       signal(SIGINT,bh)
  217. #endif
  218.  
  219. /*---------------------------------------------------------------------------
  220.  * General settings:
  221.  *-------------------------------------------------------------------------*/
  222.  
  223. #define Void     void   /* older compilers object to: typedef void Void;   */
  224. typedef unsigned Bool;
  225. #define TRUE     1
  226. #define FALSE    0
  227. typedef char    *String;
  228. typedef int      Int;
  229. typedef long     Long;
  230. typedef int      Char;
  231. typedef unsigned Unsigned;
  232.  
  233. #if     RISCOS
  234. #define STD_PRELUDE       "prelude"
  235. #else
  236. #define STD_PRELUDE       "standard.prelude"
  237. #endif
  238.  
  239. #define NUM_SYNTAX         100
  240. #define NUM_SELECTS        100
  241. #define NUM_FILES       20
  242. #define NUM_MODULES        64
  243. #define NUM_FIXUPS         100
  244. #define NUM_TUPLES         100
  245. #define NUM_OFFSETS        1024
  246. #define NUM_CHARS          256
  247.  
  248. /* Managing two different sized versions of Gofer has caused problems in
  249.  * the past for people who tried to change one setting, but inadvertantly
  250.  * modified the settings for a different size.  Now that we have three
  251.  * sizes of Gofer, I think it's time to try a new scheme:
  252.  */
  253.  
  254. #if     SMALL_GOFER            /* the McDonalds mentality :-)       */
  255. #define Pick(s,r,l)       s
  256. #endif
  257. #if     REGULAR_GOFER
  258. #define Pick(s,r,l)       r
  259. #endif
  260. #if     LARGE_GOFER
  261. #define Pick(s,r,l)       l
  262. #endif
  263.  
  264. #define NUM_TYCON          Pick(60,    160,        160)
  265. #define NUM_NAME           Pick(625,   2000,       16000)
  266. #define NUM_CLASSES        Pick(20,    40,         40)
  267. #define NUM_INSTS          Pick(60,    100,        100)
  268. #define NUM_INDEXES        Pick(700,   2000,       2000)
  269. #define NUM_DICTS          Pick(400,   32000,      32000)
  270. #define NUM_TEXT           Pick(7000,  20000,      80000)
  271. #define NUM_TEXTH       Pick(1,     10,         10)
  272. #define NUM_TYVARS         Pick(800,   3000,       4000)
  273. #define NUM_STACK          Pick(1800,  16000,      16000)
  274. #define NUM_ADDRS          Pick(28000, 100000,     320000)
  275. #define MINIMUMHEAP       Pick(7500,  7500,       7500)
  276. #define MAXIMUMHEAP       Pick(32765, 0,          0)
  277. #define DEFAULTHEAP        Pick(28000, 100000,     100000)
  278. #define MAXPOSINT          Pick(32767, 2147483647, 2147483647)
  279.  
  280. #define minRecovery       Pick(1000,  1000,       1000)
  281. #define bitsPerWord       Pick(16,    32,         32)
  282. #define wordShift       Pick(4,     5,          5)
  283. #define wordMask       Pick(15,    31,         31)
  284.  
  285. #define bitArraySize(n)    ((n)/bitsPerWord + 1)
  286. #define placeInSet(n)      ((-(n)-1)>>wordShift)
  287. #define maskInSet(n)       (1<<((-(n)-1)&wordMask))
  288.  
  289. #ifndef __GNUC__
  290. #if !RISCOS
  291. extern Int      strcmp     Args((String, String));
  292. extern Int      strlen     Args((String));
  293. extern char    *strcpy       Args((String,String));
  294. extern char     *strcat       Args((String,String));
  295. #endif
  296. #endif
  297. extern char    *getenv       Args((char *));
  298. extern int      system       Args((char *));
  299. extern double   atof       Args((char *));
  300. extern char     *strchr    Args((char *,int));  /* test membership in str  */
  301. extern Void     exit       Args((Int));
  302. extern Void     internal   Args((String));
  303. extern Void     fatal       Args((String));
  304.  
  305. #if     HAS_FLOATS
  306. #ifdef  NEED_MATH
  307. #include <math.h>
  308. #endif
  309.  
  310. #if    REGULAR_GOFER & BREAK_FLOATS
  311. #define FloatImpType       double
  312. #define FloatPro       double
  313. #else
  314. #define FloatImpType       float
  315. #define FloatPro       double  /* type to use in prototypes           */
  316.                    /* strictly ansi (i.e. gcc) conforming  */
  317.                    /* but breaks data hiding :-(       */
  318. #endif
  319. #else
  320. #define FloatImpType       int     /*dummy*/
  321. #define FloatPro       int
  322. #endif
  323.  
  324. #ifndef FILENAME_MAX       /* should already be defined in an ANSI compiler*/
  325. #define FILENAME_MAX 256
  326. #else
  327. #if     FILENAME_MAX < 256
  328. #undef  FILENAME_MAX
  329. #define FILENAME_MAX 256
  330. #endif
  331. #endif
  332.  
  333. #define DEF_EDITOR       "vi"            /* replace with ((char *)0)*/
  334. #define DEF_EDITLINE       "vi +%d %s"        /* if no default editor rqd*/
  335.  
  336. /*-------------------------------------------------------------------------*/
  337.