home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / gofer230.zip / Progs / Gofer / Lib / prelude.h < prev    next >
C/C++ Source or Header  |  1995-10-26  |  16KB  |  407 lines

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