2 /* --------------------------------------------------------------------------
3 * Basic data type definitions, prototypes and standard macros including
4 * machine dependent variations...
6 * The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the
7 * Yale Haskell Group, and the Oregon Graduate Institute of Science and
8 * Technology, 1994-1999, All rights reserved. It is distributed as
9 * free software under the license in the file "License", which is
10 * included in the distribution.
12 * $RCSfile: prelude.h,v $
14 * $Date: 2000/03/22 18:14:23 $
15 * ------------------------------------------------------------------------*/
17 #define NON_POSIX_SOURCE
18 /* AJG: machdep.h needs this, for S_IREAD and S_IFREG in cygwin? */
24 /*---------------------------------------------------------------------------
25 * Most of the configuration code from earlier versions of Hugs has been moved
26 * into config.h (which is usually automatically generated).
28 * Most of the configuration code is "feature based". That is, the
29 * configure script looks to see if a particular feature (or misfeature)
30 * is present on the compiler/OS.
32 * A small amount of configuration code is still "system based": it tests
33 * flags to determine what kind of compiler/system it's running on - from
34 * which it infers what features the compiler/system has. Use of system
35 * based tests generally indicates that we can't remember/figure out
36 * what the original problem was and so we can't add an appropriate feature
37 * test to the configure script.
38 *-------------------------------------------------------------------------*/
40 #ifdef __RISCOS__ /* Acorn DesktopC running RISCOS2 or 3 */
46 #if defined __DJGPP__ && __DJGPP__==2
52 #if defined __MSDOS__ && __MSDOS__ && !DJGPP2
58 #if defined _WIN32 | defined __WIN32__
64 /*---------------------------------------------------------------------------
65 * Platform-dependent settings:
66 *-------------------------------------------------------------------------*/
68 /*---------------------------------------------------------------------------
69 * Include windows.h and friends:
70 *-------------------------------------------------------------------------*/
73 #include <windows.h> /* Misc. Windows hackery */
77 /*---------------------------------------------------------------------------
78 * Macros used in declarations:
80 * local/far declarations
81 * HUGS_noreturn/HUGS_unused (prevent spurious warnings)
83 * dynamic linking declarations
84 *-------------------------------------------------------------------------*/
86 /* local = prefix for locally defined functions */
87 /* far = prefix for far pointers */
89 # define local near pascal
95 #ifdef __GNUC__ /* Avoid spurious warnings */
96 #if __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
97 #define HUGS_noreturn __attribute__ ((noreturn))
98 #define HUGS_unused __attribute__ ((unused))
100 #define HUGS_noreturn
104 #define HUGS_noreturn
108 /* result type of main function */
109 /* Hugs 1.01 could be configured to return void on Unix-like systems
110 * but I don't think this is necessary. ADR
113 #define MainDone() return 0/*NOTUSED*/
115 /*---------------------------------------------------------------------------
117 *-------------------------------------------------------------------------*/
122 extern int strcmp Args((const char*, const char*));
123 extern int strncmp Args((const char*, const char*, int));
124 extern char *strchr Args((const char*, int));
125 extern char *strrchr Args((const char*, int));
126 extern size_t strlen Args((const char *));
127 extern char *strcpy Args((char *, const char*));
128 extern char *strcat Args((char *, const char*));
131 #define strCompare strcmp
132 #else /* probably only used for DOS - ADR */
133 extern int stricmp Args((const char *, const char*));
134 #define strCompare stricmp
141 #define isascii(c) (((unsigned)(c))<128)
144 /*---------------------------------------------------------------------------
146 *-------------------------------------------------------------------------*/
150 # define farCalloc(n,s) farcalloc((unsigned long)n,(unsigned long)s)
154 # define farCalloc(n,s) (Void *)valloc(((unsigned)n)*((unsigned)s))
156 # define farCalloc(n,s) (Void *)calloc(((unsigned)n),((unsigned)s))
159 /* bison-generated parsers like to have alloca - so try to define it */
163 #define alloca _alloca
167 /*---------------------------------------------------------------------------
168 * Interrupting execution (signals, allowBreak):
169 *-------------------------------------------------------------------------*/
171 #if !DOS && VOID_INT_SIGNALS
172 # define sigProto(nm) void nm ( int )
173 # define sigRaise(nm) nm(1)
174 # define sigHandler(nm) void nm ( sig_arg ) int sig_arg;
175 # define sigResume return
177 # define sigProto(nm) int nm ( Void )
178 # define sigRaise(nm) nm()
179 # define sigHandler(nm) int nm ( Void )
180 # define sigResume return 1
183 /*---------------------------------------------------------------------------
185 *-------------------------------------------------------------------------*/
190 #define assert(x) doNothing()
193 /*---------------------------------------------------------------------------
195 *-------------------------------------------------------------------------*/
197 #define Void void /* older compilers object to: typedef void Void; */
198 typedef unsigned Bool;
202 typedef char *String;
206 typedef unsigned int Unsigned; /* at least 32 bits */
211 #define FloatImpType double
212 #define FloatPro double
213 #define FloatFMT "%.9g"
216 /* ToDo: this should probably go in dynamic.h - but then
217 * storage.h has to include dynamic.h!
219 #if HAVE_WINDOWS_H && !defined(__MSDOS__)
220 typedef HINSTANCE ObjectFile;
221 #elif HAVE_DLFCN_H /* eg LINUX, SOLARIS, ULTRIX */
222 typedef void* ObjectFile;
223 #elif HAVE_DL_H /* eg HPUX */
224 typedef shl_t ObjectFile;
226 #warning GHC file loading not available on this machine
229 #define doNothing() do { } while (0) /* Null statement */
233 #define STD_PRELUDE "prelude"
235 #define STD_PRELUDE "Prelude.hs"
239 /*---------------------------------------------------------------------------
240 * Printf-related operations:
241 *-------------------------------------------------------------------------*/
249 #if !defined(HAVE_SNPRINTF)
250 extern int snprintf ( char*, int, const char*, ... );
253 #if !defined(HAVE_VSNPRINTF)
254 extern int vsnprintf ( char*, int, const char*, va_list );
257 /*---------------------------------------------------------------------------
259 * Tweaking this lets us redirect prompts, error messages, etc - but has no
260 * effect on output of Haskell programs (which should use hPutStr and friends).
261 *-------------------------------------------------------------------------*/
263 #define Printf printf
264 #define Putchar putchar
265 #define FlushStdout() fflush(stdout)
266 #define EnableOutput(f) doNothing()
267 #define ClearOutputBuffer() 0
269 #define FFlush fflush
270 #define FPrintf fprintf
273 /*-------------------------------------------------------------------------*/