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 | * | |
3c205827 | 98 | * These must be defined as given here. |
0f2d19dd JB |
99 | */ |
100 | ||
101 | ||
102 | #define CCLO | |
3c205827 JB |
103 | |
104 | /* Guile Scheme supports the #f/() distinction; Guile Lisp won't. We | |
105 | have horrible plans for their unification. */ | |
106 | #undef SICP | |
0f2d19dd JB |
107 | |
108 | \f | |
109 | ||
80c78696 | 110 | /* Random options (not yet supported or in final form). */ |
0f2d19dd | 111 | |
80c78696 MD |
112 | #define STACK_CHECKING |
113 | #undef NO_CEVAL_STACK_CHECKING | |
0f2d19dd JB |
114 | #undef LONGLONGS |
115 | ||
116 | /* Some auto-generated .h files contain unused prototypes | |
117 | * that need these typedefs. | |
118 | */ | |
119 | typedef long long_long; | |
120 | typedef unsigned long ulong_long; | |
121 | ||
122 | ||
123 | \f | |
b971d089 | 124 | /* What did the configure script discover about the outside world? */ |
2a1d8241 | 125 | #include "libguile/scmconfig.h" |
b971d089 JB |
126 | |
127 | \f | |
128 | /* Write prototype declarations like this: | |
3e8a29f5 | 129 | int foo SCM_P ((int a, int b)); |
b971d089 JB |
130 | At definitions, use K&R style declarations, but make sure there's a |
131 | declarative prototype (as above) in scope. This will give you | |
132 | argument type checking, when available, and be harmless otherwise. */ | |
133 | #ifdef __STDC__ | |
3e8a29f5 | 134 | # define SCM_P(x) x |
b971d089 | 135 | #else |
72713b2f | 136 | # define SCM_P(x) () |
b971d089 JB |
137 | #endif |
138 | ||
139 | \f | |
0f2d19dd JB |
140 | |
141 | /* Define | |
142 | * | |
e2806c10 | 143 | * SCM_CHAR_CODE_LIMIT == UCHAR_MAX + 1 |
0f2d19dd JB |
144 | * SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2) |
145 | * SCM_MOST_NEGATIVE_FIXNUM == SCM_SRS((long)LONG_MIN, 2) | |
146 | */ | |
147 | ||
b971d089 | 148 | #ifdef HAVE_LIMITS_H |
0f2d19dd JB |
149 | # include <limits.h> |
150 | # ifdef UCHAR_MAX | |
e2806c10 | 151 | # define SCM_CHAR_CODE_LIMIT (UCHAR_MAX+1L) |
0f2d19dd | 152 | # else |
e2806c10 | 153 | # define SCM_CHAR_CODE_LIMIT 256L |
0f2d19dd JB |
154 | # endif /* def UCHAR_MAX */ |
155 | # define SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2) | |
156 | # ifdef _UNICOS /* Stupid cray bug */ | |
157 | # define SCM_MOST_NEGATIVE_FIXNUM ((long)LONG_MIN/4) | |
158 | # else | |
159 | # define SCM_MOST_NEGATIVE_FIXNUM SCM_SRS((long)LONG_MIN, 2) | |
160 | # endif /* UNICOS */ | |
161 | #else | |
e2806c10 | 162 | # define SCM_CHAR_CODE_LIMIT 256L |
0f2d19dd JB |
163 | # define SCM_MOST_POSITIVE_FIXNUM ((long)((unsigned long)~0L>>3)) |
164 | # if (0 != ~0) | |
165 | # define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1) | |
166 | # else | |
167 | # define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM) | |
168 | # endif /* (0 != ~0) */ | |
b971d089 | 169 | #endif /* def HAVE_LIMITS_H */ |
0f2d19dd JB |
170 | \f |
171 | ||
2a1d8241 JB |
172 | #ifdef STDC_HEADERS |
173 | # include <stdlib.h> | |
174 | # ifdef AMIGA | |
175 | # include <stddef.h> | |
176 | # endif /* def AMIGA */ | |
177 | # define scm_sizet size_t | |
178 | #else | |
179 | # ifdef _SIZE_T | |
180 | # define scm_sizet size_t | |
181 | # else | |
182 | # define scm_sizet unsigned int | |
183 | # endif /* def _SIZE_T */ | |
184 | #endif /* def STDC_HEADERS */ | |
185 | ||
186 | \f | |
187 | ||
188 | #include "libguile/tags.h" | |
0f2d19dd JB |
189 | |
190 | \f | |
191 | #ifdef vms | |
192 | # ifndef CHEAP_CONTINUATIONS | |
193 | typedef int jmp_buf[17]; | |
194 | extern int setjump(jmp_buf env); | |
195 | extern int longjump(jmp_buf env, int ret); | |
196 | # define setjmp setjump | |
197 | # define longjmp longjump | |
198 | # else | |
199 | # include <setjmp.h> | |
200 | # endif | |
201 | #else /* ndef vms */ | |
202 | # ifdef _CRAY1 | |
203 | typedef int jmp_buf[112]; | |
204 | extern int setjump(jmp_buf env); | |
205 | extern int longjump(jmp_buf env, int ret); | |
206 | # define setjmp setjump | |
207 | # define longjmp longjump | |
208 | # else /* ndef _CRAY1 */ | |
209 | # include <setjmp.h> | |
210 | # endif /* ndef _CRAY1 */ | |
211 | #endif /* ndef vms */ | |
212 | ||
0f2d19dd JB |
213 | /* James Clark came up with this neat one instruction fix for |
214 | * continuations on the SPARC. It flushes the register windows so | |
215 | * that all the state of the process is contained in the stack. | |
216 | */ | |
217 | ||
218 | #ifdef sparc | |
219 | # define SCM_FLUSH_REGISTER_WINDOWS asm("ta 3") | |
220 | #else | |
221 | # define SCM_FLUSH_REGISTER_WINDOWS /* empty */ | |
222 | #endif | |
223 | ||
224 | /* If stack is not longword aligned then | |
225 | */ | |
226 | ||
227 | /* #define SHORT_ALIGN */ | |
228 | #ifdef THINK_C | |
229 | # define SHORT_ALIGN | |
230 | #endif | |
231 | #ifdef MSDOS | |
232 | # define SHORT_ALIGN | |
233 | #endif | |
234 | #ifdef atarist | |
235 | # define SHORT_ALIGN | |
236 | #endif | |
237 | ||
238 | #ifdef SHORT_ALIGN | |
239 | typedef short SCM_STACKITEM; | |
240 | #else | |
241 | typedef long SCM_STACKITEM; | |
242 | #endif | |
243 | \f | |
244 | ||
82339094 | 245 | #ifndef USE_THREADS |
25d3ee9d MD |
246 | #define SCM_THREAD_DEFER |
247 | #define SCM_THREAD_ALLOW | |
248 | #define SCM_THREAD_REDEFER | |
249 | #define SCM_THREAD_REALLOW_1 | |
250 | #define SCM_THREAD_REALLOW_2 | |
251 | #define SCM_THREAD_SWITCHING_CODE | |
82339094 MD |
252 | #endif |
253 | ||
0f2d19dd | 254 | extern unsigned int scm_async_clock; |
25d3ee9d | 255 | #if 0 |
82339094 MD |
256 | #define SCM_ASYNC_TICK \ |
257 | { \ | |
258 | if (0 == --scm_async_clock) \ | |
259 | scm_async_click (); \ | |
82339094 MD |
260 | } \ |
261 | ||
25d3ee9d MD |
262 | #else |
263 | #define SCM_ASYNC_TICK \ | |
264 | { \ | |
265 | if (0 == --scm_async_clock) \ | |
266 | scm_async_click (); \ | |
267 | SCM_THREAD_SWITCHING_CODE; \ | |
268 | } \ | |
269 | ||
270 | #endif | |
0f2d19dd JB |
271 | |
272 | #ifdef SCM_CAREFUL_INTS | |
273 | #define SCM_CHECK_NOT_DISABLED \ | |
274 | if (scm_ints_disabled) \ | |
275 | fputs("ints already disabled\n", stderr); \ | |
276 | ||
277 | #define SCM_CHECK_NOT_ENABLED \ | |
278 | if (!scm_ints_disabled) \ | |
279 | fputs("ints already enabled\n", stderr); \ | |
280 | ||
281 | #else | |
282 | #define SCM_CHECK_NOT_DISABLED | |
283 | #define SCM_CHECK_NOT_ENABLED | |
284 | #endif | |
285 | ||
286 | ||
287 | #define SCM_DEFER_INTS \ | |
288 | { \ | |
289 | SCM_CHECK_NOT_DISABLED; \ | |
25d3ee9d | 290 | SCM_THREAD_DEFER; \ |
0f2d19dd JB |
291 | scm_ints_disabled = 1; \ |
292 | } \ | |
293 | ||
294 | ||
295 | #define SCM_ALLOW_INTS_ONLY \ | |
296 | { \ | |
25d3ee9d | 297 | SCM_THREAD_ALLOW; \ |
0f2d19dd JB |
298 | scm_ints_disabled = 0; \ |
299 | } \ | |
300 | ||
301 | ||
302 | #define SCM_ALLOW_INTS \ | |
303 | { \ | |
304 | SCM_CHECK_NOT_ENABLED; \ | |
25d3ee9d | 305 | SCM_THREAD_ALLOW; \ |
0f2d19dd JB |
306 | scm_ints_disabled = 0; \ |
307 | SCM_ASYNC_TICK; \ | |
308 | } \ | |
309 | ||
310 | ||
311 | #define SCM_REDEFER_INTS \ | |
312 | { \ | |
25d3ee9d | 313 | SCM_THREAD_REDEFER; \ |
0f2d19dd JB |
314 | ++scm_ints_disabled; \ |
315 | } \ | |
316 | ||
317 | ||
318 | #define SCM_REALLOW_INTS \ | |
319 | { \ | |
25d3ee9d | 320 | SCM_THREAD_REALLOW_1; \ |
0f2d19dd JB |
321 | --scm_ints_disabled; \ |
322 | if (!scm_ints_disabled) \ | |
25d3ee9d MD |
323 | { \ |
324 | SCM_THREAD_REALLOW_2; \ | |
325 | SCM_ASYNC_TICK; \ | |
326 | } \ | |
0f2d19dd JB |
327 | } \ |
328 | ||
329 | ||
330 | ||
331 | \f | |
332 | ||
333 | /** SCM_ASSERT | |
334 | ** | |
335 | **/ | |
336 | ||
337 | ||
338 | #ifdef SCM_RECKLESS | |
339 | #define SCM_ASSERT(_cond, _arg, _pos, _subr) | |
340 | #define SCM_ASRTGO(_cond, _label) | |
341 | #else | |
342 | #define SCM_ASSERT(_cond, _arg, _pos, _subr) \ | |
343 | if (!(_cond)) \ | |
344 | scm_wta(_arg, (char *)(_pos), _subr) | |
345 | #define SCM_ASRTGO(_cond, _label) \ | |
346 | if (!(_cond)) \ | |
347 | goto _label | |
348 | #endif | |
95b88819 | 349 | |
0f2d19dd JB |
350 | #define SCM_ARGn 0 |
351 | #define SCM_ARG1 1 | |
352 | #define SCM_ARG2 2 | |
353 | #define SCM_ARG3 3 | |
354 | #define SCM_ARG4 4 | |
355 | #define SCM_ARG5 5 | |
f5bf2977 GH |
356 | /* #define SCM_ARG6 6 |
357 | #define SCM_ARG7 7 */ | |
358 | /* #define SCM_ARGERR(X) ((X) < SCM_WNA \ | |
0f2d19dd JB |
359 | ? (char *)(X) \ |
360 | : "wrong type argument") | |
f5bf2977 | 361 | */ |
0f2d19dd JB |
362 | |
363 | /* Following must match entry indexes in scm_errmsgs[]. | |
364 | * Also, SCM_WNA must follow the last SCM_ARGn in sequence. | |
365 | */ | |
366 | #define SCM_WNA 8 | |
e1724d20 | 367 | /* #define SCM_OVSCM_FLOW 9 */ |
0f2d19dd JB |
368 | #define SCM_OUTOFRANGE 10 |
369 | #define SCM_NALLOC 11 | |
f5bf2977 GH |
370 | /* #define SCM_STACK_OVFLOW 12 */ |
371 | /* #define SCM_EXIT 13 */ | |
0f2d19dd JB |
372 | |
373 | ||
374 | /* (...still matching scm_errmsgs) These | |
375 | * are signals. Signals may become errors | |
376 | * but are distinguished because they first | |
377 | * try to invoke a handler that can resume | |
378 | * the interrupted routine. | |
379 | */ | |
380 | #define SCM_HUP_SIGNAL 14 | |
381 | #define SCM_INT_SIGNAL 15 | |
382 | #define SCM_FPE_SIGNAL 16 | |
383 | #define SCM_BUS_SIGNAL 17 | |
384 | #define SCM_SEGV_SIGNAL 18 | |
385 | #define SCM_ALRM_SIGNAL 19 | |
386 | #define SCM_GC_SIGNAL 20 | |
387 | #define SCM_TICK_SIGNAL 21 | |
388 | ||
389 | #define SCM_SIG_ORD(X) ((X) - SCM_HUP_SIGNAL) | |
390 | #define SCM_ORD_SIG(X) ((X) + SCM_HUP_SIGNAL) | |
391 | #define SCM_NUM_SIGS (SCM_SIG_ORD (SCM_TICK_SIGNAL) + 1) | |
392 | ||
82339094 | 393 | #if 0 |
0f2d19dd JB |
394 | struct errdesc |
395 | { | |
396 | char *msg; | |
397 | char *s_response; | |
398 | short parent_err; | |
399 | }; | |
400 | ||
401 | ||
402 | extern struct errdesc scm_errmsgs[]; | |
82339094 | 403 | #endif |
0f2d19dd JB |
404 | |
405 | \f | |
406 | ||
407 | /* SCM_EXIT_SUCCESS is the default code to return from SCM if no errors | |
408 | * were encountered. SCM_EXIT_FAILURE is the default code to return from | |
409 | * SCM if errors were encountered. The return code can be explicitly | |
410 | * specified in a SCM program with (scm_quit <n>). | |
411 | */ | |
412 | ||
413 | #ifndef SCM_EXIT_SUCCESS | |
414 | #ifdef vms | |
415 | #define SCM_EXIT_SUCCESS 1 | |
416 | #else | |
417 | #define SCM_EXIT_SUCCESS 0 | |
418 | #endif /* def vms */ | |
419 | #endif /* ndef SCM_EXIT_SUCCESS */ | |
420 | #ifndef SCM_EXIT_FAILURE | |
421 | #ifdef vms | |
422 | #define SCM_EXIT_FAILURE 2 | |
423 | #else | |
424 | #define SCM_EXIT_FAILURE 1 | |
425 | #endif /* def vms */ | |
426 | #endif /* ndef SCM_EXIT_FAILURE */ | |
427 | ||
428 | ||
429 | ||
430 | \f | |
0f2d19dd JB |
431 | |
432 | #endif /* __SCMH */ |