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: hugsbasictypes.h,v $
14 * $Date: 2000/04/05 14:13:58 $
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 /*---------------------------------------------------------------------------
169 *-------------------------------------------------------------------------*/
174 #define assert(x) doNothing()
177 /*---------------------------------------------------------------------------
179 *-------------------------------------------------------------------------*/
181 #define Void void /* older compilers object to: typedef void Void; */
182 typedef unsigned Bool;
186 typedef char *String;
190 typedef unsigned int Unsigned; /* at least 32 bits */
195 #define FloatImpType double
196 #define FloatPro double
197 #define FloatFMT "%.9g"
200 /* ToDo: this should probably go in dynamic.h - but then
201 * storage.h has to include dynamic.h!
203 #if HAVE_WINDOWS_H && !defined(__MSDOS__)
204 typedef HINSTANCE ObjectFile;
205 #elif HAVE_DLFCN_H /* eg LINUX, SOLARIS, ULTRIX */
206 typedef void* ObjectFile;
207 #elif HAVE_DL_H /* eg HPUX */
208 typedef shl_t ObjectFile;
210 #warning GHC file loading not available on this machine
213 #define doNothing() do { } while (0) /* Null statement */
217 #define STD_PRELUDE "prelude"
219 #define STD_PRELUDE "Prelude.hs"
223 /*---------------------------------------------------------------------------
224 * Printf-related operations:
225 *-------------------------------------------------------------------------*/
233 #if !defined(HAVE_SNPRINTF)
234 extern int snprintf ( char*, int, const char*, ... );
237 #if !defined(HAVE_VSNPRINTF)
238 extern int vsnprintf ( char*, int, const char*, va_list );
241 /*---------------------------------------------------------------------------
243 * Tweaking this lets us redirect prompts, error messages, etc - but has no
244 * effect on output of Haskell programs (which should use hPutStr and friends).
245 *-------------------------------------------------------------------------*/
247 extern Void hugsPrintf (const char *, ...);
248 extern Void hugsPutchar (int);
249 extern Void hugsFlushStdout (Void);
250 extern Void hugsEnableOutput (Bool);
252 extern Void hugsFFlush (FILE*);
253 extern Void hugsFPrintf (FILE*, const char*, ...);
254 extern Void hugsPutc (int, FILE*);
256 #define Printf hugsPrintf
257 #define Putchar hugsPutchar
258 #define FlushStdout hugsFlushStdout
259 #define EnableOutput hugsEnableOutput
260 #define ClearOutputBuffer hugsClearOutputBuffer
262 #define FFlush hugsFFlush
263 #define FPrintf hugsFPrintf
264 #define Putc hugsPutc
266 /*-------------------------------------------------------------------------*/