Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
3 | #ifndef __SCMH | |
4 | #define __SCMH | |
5 | /* Copyright (C) 1995, 1996 Free Software Foundation, Inc. | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2, or (at your option) | |
10 | * any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this software; see the file COPYING. If not, write to | |
19 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | * | |
21 | * As a special exception, the Free Software Foundation gives permission | |
22 | * for additional uses of the text contained in its release of GUILE. | |
23 | * | |
24 | * The exception is that, if you link the GUILE library with other files | |
25 | * to produce an executable, this does not by itself cause the | |
26 | * resulting executable to be covered by the GNU General Public License. | |
27 | * Your use of that executable is in no way restricted on account of | |
28 | * linking the GUILE library code into it. | |
29 | * | |
30 | * This exception does not however invalidate any other reasons why | |
31 | * the executable file might be covered by the GNU General Public License. | |
32 | * | |
33 | * This exception applies only to the code released by the | |
34 | * Free Software Foundation under the name GUILE. If you copy | |
35 | * code from other Free Software Foundation releases into a copy of | |
36 | * GUILE, as the General Public License permits, the exception does | |
37 | * not apply to the code that you add in this way. To avoid misleading | |
38 | * anyone as to the status of such modified files, you must delete | |
39 | * this exception notice from them. | |
40 | * | |
41 | * If you write modifications of your own for GUILE, it is your choice | |
42 | * whether to permit this exception to apply to your modifications. | |
43 | * If you do not wish that, delete this exception notice. | |
44 | */ | |
45 | \f | |
46 | /* {Supported Options} | |
47 | * | |
48 | * These may be defined or undefined. | |
49 | */ | |
50 | ||
51 | /* If the compile FLAG `CAUTIOUS' is #defined then the number of | |
52 | * arguments is always checked for application of closures. If the | |
53 | * compile FLAG `RECKLESS' is #defined then they are not checked. | |
54 | * Otherwise, number of argument checks for closures are made only when | |
55 | * the function position (whose value is the closure) of a combination is | |
56 | * not an ILOC or GLOC. When the function position of a combination is a | |
57 | * symbol it will be checked only the first time it is evaluated because | |
58 | * it will then be replaced with an ILOC or GLOC. | |
59 | */ | |
60 | #undef RECKLESS | |
61 | #define CAUTIOUS | |
62 | ||
63 | /* After looking up a local for the first time, rewrite the | |
64 | * code graph, caching its position. | |
65 | */ | |
66 | #define MEMOIZE_LOCALS | |
67 | ||
68 | /* All the number support there is. | |
69 | */ | |
70 | #define SCM_FLOATS | |
71 | #define BIGNUMS | |
72 | ||
73 | /* GC should relinquish empty cons-pair arenas. | |
74 | */ | |
75 | #define GC_FREE_SEGMENTS | |
76 | ||
77 | /* Provide a scheme-accessible count-down timer that | |
78 | * generates a pseudo-interrupt. | |
79 | */ | |
80 | #define TICKS | |
81 | ||
82 | ||
83 | /* Use engineering notation when converting numbers strings? | |
84 | */ | |
85 | #undef ENGNOT | |
86 | ||
87 | /* Include support for uniform arrays? | |
88 | * | |
89 | * Possibly some of the initialization code depends on this | |
90 | * being defined, but that is a bug and should be fixed. | |
91 | */ | |
92 | #define ARRAYS | |
93 | ||
94 | #undef SCM_CAREFUL_INTS | |
95 | \f | |
96 | /* {Unsupported Options} | |
97 | * | |
98 | * These must be defined. | |
99 | */ | |
100 | ||
101 | ||
102 | #define CCLO | |
103 | #define SICP | |
104 | ||
105 | \f | |
106 | ||
80c78696 | 107 | /* Random options (not yet supported or in final form). */ |
0f2d19dd | 108 | |
80c78696 MD |
109 | #define STACK_CHECKING |
110 | #undef NO_CEVAL_STACK_CHECKING | |
0f2d19dd JB |
111 | #undef LONGLONGS |
112 | ||
113 | /* Some auto-generated .h files contain unused prototypes | |
114 | * that need these typedefs. | |
115 | */ | |
116 | typedef long long_long; | |
117 | typedef unsigned long ulong_long; | |
118 | ||
119 | ||
120 | \f | |
b971d089 | 121 | /* What did the configure script discover about the outside world? */ |
2a1d8241 | 122 | #include "libguile/scmconfig.h" |
b971d089 JB |
123 | |
124 | \f | |
125 | /* Write prototype declarations like this: | |
3e8a29f5 | 126 | int foo SCM_P ((int a, int b)); |
b971d089 JB |
127 | At definitions, use K&R style declarations, but make sure there's a |
128 | declarative prototype (as above) in scope. This will give you | |
129 | argument type checking, when available, and be harmless otherwise. */ | |
130 | #ifdef __STDC__ | |
3e8a29f5 | 131 | # define SCM_P(x) x |
b971d089 | 132 | #else |
72713b2f | 133 | # define SCM_P(x) () |
b971d089 JB |
134 | #endif |
135 | ||
136 | \f | |
0f2d19dd JB |
137 | |
138 | /* Define | |
139 | * | |
e2806c10 | 140 | * SCM_CHAR_CODE_LIMIT == UCHAR_MAX + 1 |
0f2d19dd JB |
141 | * SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2) |
142 | * SCM_MOST_NEGATIVE_FIXNUM == SCM_SRS((long)LONG_MIN, 2) | |
143 | */ | |
144 | ||
b971d089 | 145 | #ifdef HAVE_LIMITS_H |
0f2d19dd JB |
146 | # include <limits.h> |
147 | # ifdef UCHAR_MAX | |
e2806c10 | 148 | # define SCM_CHAR_CODE_LIMIT (UCHAR_MAX+1L) |
0f2d19dd | 149 | # else |
e2806c10 | 150 | # define SCM_CHAR_CODE_LIMIT 256L |
0f2d19dd JB |
151 | # endif /* def UCHAR_MAX */ |
152 | # define SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2) | |
153 | # ifdef _UNICOS /* Stupid cray bug */ | |
154 | # define SCM_MOST_NEGATIVE_FIXNUM ((long)LONG_MIN/4) | |
155 | # else | |
156 | # define SCM_MOST_NEGATIVE_FIXNUM SCM_SRS((long)LONG_MIN, 2) | |
157 | # endif /* UNICOS */ | |
158 | #else | |
e2806c10 | 159 | # define SCM_CHAR_CODE_LIMIT 256L |
0f2d19dd JB |
160 | # define SCM_MOST_POSITIVE_FIXNUM ((long)((unsigned long)~0L>>3)) |
161 | # if (0 != ~0) | |
162 | # define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1) | |
163 | # else | |
164 | # define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM) | |
165 | # endif /* (0 != ~0) */ | |
b971d089 | 166 | #endif /* def HAVE_LIMITS_H */ |
0f2d19dd JB |
167 | \f |
168 | ||
2a1d8241 JB |
169 | #ifdef STDC_HEADERS |
170 | # include <stdlib.h> | |
171 | # ifdef AMIGA | |
172 | # include <stddef.h> | |
173 | # endif /* def AMIGA */ | |
174 | # define scm_sizet size_t | |
175 | #else | |
176 | # ifdef _SIZE_T | |
177 | # define scm_sizet size_t | |
178 | # else | |
179 | # define scm_sizet unsigned int | |
180 | # endif /* def _SIZE_T */ | |
181 | #endif /* def STDC_HEADERS */ | |
182 | ||
183 | \f | |
184 | ||
185 | #include "libguile/tags.h" | |
0f2d19dd JB |
186 | |
187 | \f | |
188 | #ifdef vms | |
189 | # ifndef CHEAP_CONTINUATIONS | |
190 | typedef int jmp_buf[17]; | |
191 | extern int setjump(jmp_buf env); | |
192 | extern int longjump(jmp_buf env, int ret); | |
193 | # define setjmp setjump | |
194 | # define longjmp longjump | |
195 | # else | |
196 | # include <setjmp.h> | |
197 | # endif | |
198 | #else /* ndef vms */ | |
199 | # ifdef _CRAY1 | |
200 | typedef int jmp_buf[112]; | |
201 | extern int setjump(jmp_buf env); | |
202 | extern int longjump(jmp_buf env, int ret); | |
203 | # define setjmp setjump | |
204 | # define longjmp longjump | |
205 | # else /* ndef _CRAY1 */ | |
206 | # include <setjmp.h> | |
207 | # endif /* ndef _CRAY1 */ | |
208 | #endif /* ndef vms */ | |
209 | ||
0f2d19dd JB |
210 | /* James Clark came up with this neat one instruction fix for |
211 | * continuations on the SPARC. It flushes the register windows so | |
212 | * that all the state of the process is contained in the stack. | |
213 | */ | |
214 | ||
215 | #ifdef sparc | |
216 | # define SCM_FLUSH_REGISTER_WINDOWS asm("ta 3") | |
217 | #else | |
218 | # define SCM_FLUSH_REGISTER_WINDOWS /* empty */ | |
219 | #endif | |
220 | ||
221 | /* If stack is not longword aligned then | |
222 | */ | |
223 | ||
224 | /* #define SHORT_ALIGN */ | |
225 | #ifdef THINK_C | |
226 | # define SHORT_ALIGN | |
227 | #endif | |
228 | #ifdef MSDOS | |
229 | # define SHORT_ALIGN | |
230 | #endif | |
231 | #ifdef atarist | |
232 | # define SHORT_ALIGN | |
233 | #endif | |
234 | ||
235 | #ifdef SHORT_ALIGN | |
236 | typedef short SCM_STACKITEM; | |
237 | #else | |
238 | typedef long SCM_STACKITEM; | |
239 | #endif | |
240 | \f | |
241 | ||
242 | extern unsigned int scm_async_clock; | |
243 | #define SCM_ASYNC_TICK if (0 == --scm_async_clock) scm_async_click () | |
244 | ||
245 | #ifdef SCM_CAREFUL_INTS | |
246 | #define SCM_CHECK_NOT_DISABLED \ | |
247 | if (scm_ints_disabled) \ | |
248 | fputs("ints already disabled\n", stderr); \ | |
249 | ||
250 | #define SCM_CHECK_NOT_ENABLED \ | |
251 | if (!scm_ints_disabled) \ | |
252 | fputs("ints already enabled\n", stderr); \ | |
253 | ||
254 | #else | |
255 | #define SCM_CHECK_NOT_DISABLED | |
256 | #define SCM_CHECK_NOT_ENABLED | |
257 | #endif | |
258 | ||
259 | ||
260 | #define SCM_DEFER_INTS \ | |
261 | { \ | |
262 | SCM_CHECK_NOT_DISABLED; \ | |
263 | scm_ints_disabled = 1; \ | |
264 | } \ | |
265 | ||
266 | ||
267 | #define SCM_ALLOW_INTS_ONLY \ | |
268 | { \ | |
269 | scm_ints_disabled = 0; \ | |
270 | } \ | |
271 | ||
272 | ||
273 | #define SCM_ALLOW_INTS \ | |
274 | { \ | |
275 | SCM_CHECK_NOT_ENABLED; \ | |
276 | scm_ints_disabled = 0; \ | |
277 | SCM_ASYNC_TICK; \ | |
278 | } \ | |
279 | ||
280 | ||
281 | #define SCM_REDEFER_INTS \ | |
282 | { \ | |
283 | ++scm_ints_disabled; \ | |
284 | } \ | |
285 | ||
286 | ||
287 | #define SCM_REALLOW_INTS \ | |
288 | { \ | |
289 | --scm_ints_disabled; \ | |
290 | if (!scm_ints_disabled) \ | |
291 | SCM_ASYNC_TICK; \ | |
292 | } \ | |
293 | ||
294 | ||
295 | ||
296 | \f | |
297 | ||
298 | /** SCM_ASSERT | |
299 | ** | |
300 | **/ | |
301 | ||
302 | ||
303 | #ifdef SCM_RECKLESS | |
304 | #define SCM_ASSERT(_cond, _arg, _pos, _subr) | |
305 | #define SCM_ASRTGO(_cond, _label) | |
306 | #else | |
307 | #define SCM_ASSERT(_cond, _arg, _pos, _subr) \ | |
308 | if (!(_cond)) \ | |
309 | scm_wta(_arg, (char *)(_pos), _subr) | |
310 | #define SCM_ASRTGO(_cond, _label) \ | |
311 | if (!(_cond)) \ | |
312 | goto _label | |
313 | #endif | |
95b88819 | 314 | |
7cb1d4d3 GH |
315 | #define lgh_error(_key, _subr, _message, _args, _rest) \ |
316 | scm_error (_key, _subr, _message, _args, _rest) | |
317 | ||
0f2d19dd JB |
318 | #define SCM_ARGn 0 |
319 | #define SCM_ARG1 1 | |
320 | #define SCM_ARG2 2 | |
321 | #define SCM_ARG3 3 | |
322 | #define SCM_ARG4 4 | |
323 | #define SCM_ARG5 5 | |
f5bf2977 GH |
324 | /* #define SCM_ARG6 6 |
325 | #define SCM_ARG7 7 */ | |
326 | /* #define SCM_ARGERR(X) ((X) < SCM_WNA \ | |
0f2d19dd JB |
327 | ? (char *)(X) \ |
328 | : "wrong type argument") | |
f5bf2977 | 329 | */ |
0f2d19dd JB |
330 | |
331 | /* Following must match entry indexes in scm_errmsgs[]. | |
332 | * Also, SCM_WNA must follow the last SCM_ARGn in sequence. | |
333 | */ | |
334 | #define SCM_WNA 8 | |
e1724d20 | 335 | /* #define SCM_OVSCM_FLOW 9 */ |
0f2d19dd JB |
336 | #define SCM_OUTOFRANGE 10 |
337 | #define SCM_NALLOC 11 | |
f5bf2977 GH |
338 | /* #define SCM_STACK_OVFLOW 12 */ |
339 | /* #define SCM_EXIT 13 */ | |
0f2d19dd JB |
340 | |
341 | ||
342 | /* (...still matching scm_errmsgs) These | |
343 | * are signals. Signals may become errors | |
344 | * but are distinguished because they first | |
345 | * try to invoke a handler that can resume | |
346 | * the interrupted routine. | |
347 | */ | |
348 | #define SCM_HUP_SIGNAL 14 | |
349 | #define SCM_INT_SIGNAL 15 | |
350 | #define SCM_FPE_SIGNAL 16 | |
351 | #define SCM_BUS_SIGNAL 17 | |
352 | #define SCM_SEGV_SIGNAL 18 | |
353 | #define SCM_ALRM_SIGNAL 19 | |
354 | #define SCM_GC_SIGNAL 20 | |
355 | #define SCM_TICK_SIGNAL 21 | |
356 | ||
357 | #define SCM_SIG_ORD(X) ((X) - SCM_HUP_SIGNAL) | |
358 | #define SCM_ORD_SIG(X) ((X) + SCM_HUP_SIGNAL) | |
359 | #define SCM_NUM_SIGS (SCM_SIG_ORD (SCM_TICK_SIGNAL) + 1) | |
360 | ||
361 | struct errdesc | |
362 | { | |
363 | char *msg; | |
364 | char *s_response; | |
365 | short parent_err; | |
366 | }; | |
367 | ||
368 | ||
369 | extern struct errdesc scm_errmsgs[]; | |
370 | ||
371 | \f | |
372 | ||
373 | /* SCM_EXIT_SUCCESS is the default code to return from SCM if no errors | |
374 | * were encountered. SCM_EXIT_FAILURE is the default code to return from | |
375 | * SCM if errors were encountered. The return code can be explicitly | |
376 | * specified in a SCM program with (scm_quit <n>). | |
377 | */ | |
378 | ||
379 | #ifndef SCM_EXIT_SUCCESS | |
380 | #ifdef vms | |
381 | #define SCM_EXIT_SUCCESS 1 | |
382 | #else | |
383 | #define SCM_EXIT_SUCCESS 0 | |
384 | #endif /* def vms */ | |
385 | #endif /* ndef SCM_EXIT_SUCCESS */ | |
386 | #ifndef SCM_EXIT_FAILURE | |
387 | #ifdef vms | |
388 | #define SCM_EXIT_FAILURE 2 | |
389 | #else | |
390 | #define SCM_EXIT_FAILURE 1 | |
391 | #endif /* def vms */ | |
392 | #endif /* ndef SCM_EXIT_FAILURE */ | |
393 | ||
394 | ||
395 | ||
396 | \f | |
397 | #ifdef __STDC__ | |
398 | ||
399 | #else /* STDC */ | |
400 | ||
401 | #endif /* STDC */ | |
402 | ||
403 | ||
404 | #endif /* __SCMH */ |