[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / interpreter / machdep.h
1 /* -*- mode: hugs-c; -*- */
2 /*---------------------------------------------------------------------------
3  * Interrupting execution (signals, allowBreak):
4  *-------------------------------------------------------------------------*/
5
6 extern Bool breakOn      Args((Bool));
7
8 extern Bool  broken;                    /* indicates interrupt received    */
9
10 #ifndef SIGBREAK /* Sigh, not defined in cygwin32 beta release 16 */
11 # define SIGBREAK 21
12 #endif
13
14 /* allowBreak: call to allow user to interrupt computation
15  * ctrlbrk:    set control break handler
16  */
17
18 #if HUGS_FOR_WINDOWS
19 #  define ctrlbrk(bh) 
20 #  define allowBreak()  kbhit()
21 #else /* !HUGS_FOR_WINDOWS */
22 #  define ctrlbrk(bh)   signal(SIGINT,bh); signal(SIGBREAK,bh)
23 #  define allowBreak()  if (broken) { broken=FALSE; sigRaise(breakHandler); }
24 #endif /* !HUGS_FOR_WINDOWS */
25
26 /*---------------------------------------------------------------------------
27  * Environment variables and the registry
28  *-------------------------------------------------------------------------*/
29
30 /* On Win32 we can use the registry to supplement info in environment 
31  * variables.
32  */
33 #define USE_REGISTRY (HAVE_WINDOWS_H && !__MSDOS__)
34
35 #ifdef USE_REGISTRY
36 Bool    writeRegString Args((String var, String val));
37 String  readRegString  Args((String var, String def));
38 Int     readRegInt     Args((String var, Int def));
39 Bool    writeRegInt    Args((String var, Int val));
40 #endif
41
42 /*---------------------------------------------------------------------------
43  * File operations:
44  *-------------------------------------------------------------------------*/
45
46 #if HAVE_UNISTD_H
47 # include <sys/types.h>
48 # include <unistd.h>
49 #elif !HUGS_FOR_WINDOWS
50 extern int      chdir      Args((const char*));
51 #endif
52
53 #if HAVE_STDLIB_H
54 # include <stdlib.h>
55 #else
56 extern int      system     Args((const char *));
57 extern double   atof       Args((const char *));
58 extern void     exit       Args((int));
59 #endif
60
61 #ifndef FILENAME_MAX       /* should already be defined in an ANSI compiler*/
62 #define FILENAME_MAX 256
63 #else
64 #if     FILENAME_MAX < 256
65 #undef  FILENAME_MAX
66 #define FILENAME_MAX 256
67 #endif
68 #endif
69
70 /* Hack, hack: if you have dos.h, you probably have a DOS filesystem */
71 #define DOS_FILENAMES              HAVE_DOS_H
72 /* ToDo: can we replace this with a feature test? */
73 #define MAC_FILENAMES              SYMANTEC_C
74
75 #define CASE_INSENSITIVE_FILENAMES (DOS_FILENAMES | RISCOS)
76
77 #if CASE_INSENSITIVE_FILENAMES
78 # if HAVE_STRCASECMP
79 #  define filenamecmp(s1,s2) strcasecmp(s1,s2)
80 # elif HAVE__STRICMP
81 #  define filenamecmp(s1,s2) _stricmp(s1,s2)
82 # elif HAVE_STRICMP
83 #  define filenamecmp(s1,s2) stricmp(s1,s2)
84 # elif HAVE_STRCMPI
85 #  define filenamecmp(s1,s2) strcmpi(s1,s2)
86 # endif
87 #else
88 # define filenamecmp(s1,s2) strcmp(s1,s2)
89 #endif
90
91 /*---------------------------------------------------------------------------
92  * Pipe-related operations:
93  *
94  * On Windows, many standard Unix names acquire a leading underscore.
95  * Irritating, but easy to work around.
96  *-------------------------------------------------------------------------*/
97
98 #if !defined(HAVE_POPEN) && defined(HAVE__POPEN)
99 #define popen(x,y) _popen(x,y)
100 #endif
101 #if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE)
102 #define pclose(x) _pclose(x)
103 #endif
104
105 /*---------------------------------------------------------------------------
106  * Bit manipulation:
107  *-------------------------------------------------------------------------*/
108
109 #define bitArraySize(n)    ((n)/bitsPerWord + 1)
110 #define placeInSet(n)      ((-(n)-1)>>wordShift)
111 #define maskInSet(n)       (1<<((-(n)-1)&wordMask))
112
113 /*---------------------------------------------------------------------------
114  * Function prototypes for code in machdep.c
115  *-------------------------------------------------------------------------*/
116
117 #if RISCOS
118 typedef struct { unsigned hi, lo; } Time;
119 #define timeChanged(now,thn)    (now.hi!=thn.hi || now.lo!=thn.lo)
120 #define timeSet(var,tm)         var.hi = tm.hi; var.lo = tm.lo
121 #else
122 typedef time_t Time;
123 #define timeChanged(now,thn)    (now!=thn)
124 #define timeSet(var,tm)         var = tm
125 #endif
126
127 extern Void   getFileInfo      Args((String, Time *, Long *));
128 extern int    pathCmp          Args((String, String));
129 extern String substPath        Args((String,String));
130 extern Bool   startEdit        Args((Int,String));
131
132 extern  String findPathname     Args((String,String));
133 extern  String findMPathname    Args((String,String));
134
135 extern  Int    shellEsc         Args((String));
136 extern  Int    getTerminalWidth Args((Void));
137 extern  Void   normalTerminal   Args((Void));
138 extern  Void   noechoTerminal   Args((Void));
139 extern  Int    readTerminalChar Args((Void));
140 extern  Void   gcStarted        Args((Void));
141 extern  Void   gcScanning       Args((Void));
142 extern  Void   gcRecovered      Args((Int));
143 extern  Void   gcCStack         Args((Void));
144
145 /*-------------------------------------------------------------------------*/