Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
3 | #ifndef __SCMH | |
4 | #define __SCMH | |
cd911565 | 5 | /* Copyright (C) 1995, 1996, 1998, 1999, 2000 Free Software Foundation, Inc. |
0f2d19dd JB |
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 | |
82892bed JB |
19 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
20 | * Boston, MA 02111-1307 USA | |
0f2d19dd JB |
21 | * |
22 | * As a special exception, the Free Software Foundation gives permission | |
23 | * for additional uses of the text contained in its release of GUILE. | |
24 | * | |
25 | * The exception is that, if you link the GUILE library with other files | |
26 | * to produce an executable, this does not by itself cause the | |
27 | * resulting executable to be covered by the GNU General Public License. | |
28 | * Your use of that executable is in no way restricted on account of | |
29 | * linking the GUILE library code into it. | |
30 | * | |
31 | * This exception does not however invalidate any other reasons why | |
32 | * the executable file might be covered by the GNU General Public License. | |
33 | * | |
34 | * This exception applies only to the code released by the | |
35 | * Free Software Foundation under the name GUILE. If you copy | |
36 | * code from other Free Software Foundation releases into a copy of | |
37 | * GUILE, as the General Public License permits, the exception does | |
38 | * not apply to the code that you add in this way. To avoid misleading | |
39 | * anyone as to the status of such modified files, you must delete | |
40 | * this exception notice from them. | |
41 | * | |
42 | * If you write modifications of your own for GUILE, it is your choice | |
43 | * whether to permit this exception to apply to your modifications. | |
82892bed | 44 | * If you do not wish that, delete this exception notice. */ |
0f2d19dd | 45 | \f |
176067df JB |
46 | |
47 | /* "What's the difference between _scm.h and __scm.h?" | |
48 | ||
49 | _scm.h is not installed; it's only visible to the libguile sources | |
50 | themselves. | |
51 | ||
52 | __scm.h is installed, and is #included by <libguile.h>. If both | |
53 | the client and libguile need some piece of information, and it | |
54 | doesn't fit well into the header file for any particular module, it | |
55 | should go in __scm.h. */ | |
56 | ||
57 | ||
0f2d19dd JB |
58 | /* {Supported Options} |
59 | * | |
60 | * These may be defined or undefined. | |
61 | */ | |
62 | ||
9f0e55a6 MD |
63 | /* Old async mechanism */ |
64 | /* #define GUILE_OLD_ASYNC_CLICK */ | |
65 | ||
83c4c29d | 66 | /* New scheme for garbage collection */ |
d2f51eaf | 67 | #define GUILE_NEW_GC_SCHEME |
83c4c29d | 68 | |
16d35552 | 69 | /* #define GUILE_DEBUG_FREELIST */ |
70d63753 | 70 | |
cf7c17e9 | 71 | /* If the compile FLAG `SCM_CAUTIOUS' is #defined then the number of |
0f2d19dd | 72 | * arguments is always checked for application of closures. If the |
cf7c17e9 | 73 | * compile FLAG `SCM_RECKLESS' is #defined then they are not checked. |
0f2d19dd JB |
74 | * Otherwise, number of argument checks for closures are made only when |
75 | * the function position (whose value is the closure) of a combination is | |
76 | * not an ILOC or GLOC. When the function position of a combination is a | |
77 | * symbol it will be checked only the first time it is evaluated because | |
78 | * it will then be replaced with an ILOC or GLOC. | |
79 | */ | |
cf7c17e9 JB |
80 | #undef SCM_RECKLESS |
81 | #define SCM_CAUTIOUS | |
0f2d19dd JB |
82 | |
83 | /* After looking up a local for the first time, rewrite the | |
84 | * code graph, caching its position. | |
85 | */ | |
86 | #define MEMOIZE_LOCALS | |
87 | ||
88 | /* All the number support there is. | |
89 | */ | |
0f2d19dd JB |
90 | #define BIGNUMS |
91 | ||
92 | /* GC should relinquish empty cons-pair arenas. | |
93 | */ | |
d2f51eaf | 94 | #ifndef GUILE_NEW_GC_SCHEME |
0f2d19dd | 95 | #define GC_FREE_SEGMENTS |
d2f51eaf | 96 | #endif |
0f2d19dd JB |
97 | |
98 | /* Provide a scheme-accessible count-down timer that | |
99 | * generates a pseudo-interrupt. | |
100 | */ | |
101 | #define TICKS | |
102 | ||
103 | ||
104 | /* Use engineering notation when converting numbers strings? | |
105 | */ | |
106 | #undef ENGNOT | |
107 | ||
0f2d19dd JB |
108 | #undef SCM_CAREFUL_INTS |
109 | \f | |
110 | /* {Unsupported Options} | |
111 | * | |
3c205827 | 112 | * These must be defined as given here. |
0f2d19dd JB |
113 | */ |
114 | ||
115 | ||
116 | #define CCLO | |
3c205827 JB |
117 | |
118 | /* Guile Scheme supports the #f/() distinction; Guile Lisp won't. We | |
119 | have horrible plans for their unification. */ | |
120 | #undef SICP | |
0f2d19dd JB |
121 | |
122 | \f | |
123 | ||
80c78696 | 124 | /* Random options (not yet supported or in final form). */ |
0f2d19dd | 125 | |
80c78696 MD |
126 | #define STACK_CHECKING |
127 | #undef NO_CEVAL_STACK_CHECKING | |
0f2d19dd | 128 | |
43ff3170 | 129 | \f |
3a9809df | 130 | |
43ff3170 GH |
131 | /* What did the configure script discover about the outside world? */ |
132 | #include "libguile/scmconfig.h" | |
133 | ||
3a9809df DH |
134 | \f |
135 | ||
136 | /* {Debugging Options} | |
137 | * | |
138 | * These compile time options determine whether to include code that is only | |
139 | * useful for debugging guile itself or C level extensions to guile. The | |
140 | * common prefix for all option macros of this kind is "SCM_DEBUG_". It is | |
141 | * guaranteed that a macro named SCM_DEBUG_XXX is defined to be either 0 or 1, | |
142 | * i. e. there is no need to test for the undefined case. This allows to use | |
143 | * these definitions comfortably in macro code, as in the following example: | |
144 | * #define FOO do { if (SCM_DEBUG_XXX) bar(); else baz(); } while (0) | |
145 | * Any sane compiler will remove the unused branch without any performance | |
146 | * penalty for the resulting code. | |
147 | * | |
148 | * Note: Some SCM_DEBUG_XXX options are not settable at configure time. | |
149 | * To change the value of such options you will have to edit this header | |
56100716 DH |
150 | * file or give suitable options to make, like: |
151 | * make all CFLAGS="-DSCM_DEBUG_XXX=1 ..." | |
3a9809df DH |
152 | */ |
153 | ||
154 | ||
155 | /* If SCM_DEBUG_DEPRECATED is set to 1, deprecated code is not compiled. This | |
156 | * can be used by developers to get rid of references to deprecated code. | |
157 | */ | |
158 | #ifndef SCM_DEBUG_DEPRECATED | |
159 | #define SCM_DEBUG_DEPRECATED 0 | |
160 | #endif | |
161 | ||
56100716 DH |
162 | /* Use this for _compile time_ type checking only, since the compiled result |
163 | * will be quite inefficient. The right way to make use of this option is to | |
164 | * do a 'make clean; make CFLAGS=-DSCM_DEBUG_TYPING_STRICTNESS=1', fix your | |
165 | * errors, and then do 'make clean; make'. | |
166 | */ | |
167 | #ifndef SCM_DEBUG_TYPING_STRICTNESS | |
168 | #define SCM_DEBUG_TYPING_STRICTNESS 0 | |
169 | #endif | |
170 | ||
3a9809df DH |
171 | \f |
172 | ||
43ff3170 GH |
173 | #ifdef HAVE_LONG_LONGS |
174 | ||
0f2d19dd JB |
175 | /* Some auto-generated .h files contain unused prototypes |
176 | * that need these typedefs. | |
177 | */ | |
afe5177e GH |
178 | typedef long long long_long; |
179 | typedef unsigned long long ulong_long; | |
0f2d19dd | 180 | |
43ff3170 | 181 | #endif /* HAVE_LONG_LONGS */ |
b971d089 JB |
182 | |
183 | \f | |
0f2d19dd JB |
184 | |
185 | /* Define | |
186 | * | |
e2806c10 | 187 | * SCM_CHAR_CODE_LIMIT == UCHAR_MAX + 1 |
0f2d19dd JB |
188 | * SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2) |
189 | * SCM_MOST_NEGATIVE_FIXNUM == SCM_SRS((long)LONG_MIN, 2) | |
190 | */ | |
191 | ||
b971d089 | 192 | #ifdef HAVE_LIMITS_H |
0f2d19dd JB |
193 | # include <limits.h> |
194 | # ifdef UCHAR_MAX | |
e2806c10 | 195 | # define SCM_CHAR_CODE_LIMIT (UCHAR_MAX+1L) |
0f2d19dd | 196 | # else |
e2806c10 | 197 | # define SCM_CHAR_CODE_LIMIT 256L |
0f2d19dd JB |
198 | # endif /* def UCHAR_MAX */ |
199 | # define SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2) | |
200 | # ifdef _UNICOS /* Stupid cray bug */ | |
201 | # define SCM_MOST_NEGATIVE_FIXNUM ((long)LONG_MIN/4) | |
202 | # else | |
203 | # define SCM_MOST_NEGATIVE_FIXNUM SCM_SRS((long)LONG_MIN, 2) | |
204 | # endif /* UNICOS */ | |
205 | #else | |
e2806c10 | 206 | # define SCM_CHAR_CODE_LIMIT 256L |
0f2d19dd JB |
207 | # define SCM_MOST_POSITIVE_FIXNUM ((long)((unsigned long)~0L>>3)) |
208 | # if (0 != ~0) | |
209 | # define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1) | |
210 | # else | |
211 | # define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM) | |
212 | # endif /* (0 != ~0) */ | |
b971d089 | 213 | #endif /* def HAVE_LIMITS_H */ |
0f2d19dd JB |
214 | \f |
215 | ||
2a1d8241 JB |
216 | #ifdef STDC_HEADERS |
217 | # include <stdlib.h> | |
218 | # ifdef AMIGA | |
219 | # include <stddef.h> | |
220 | # endif /* def AMIGA */ | |
221 | # define scm_sizet size_t | |
222 | #else | |
223 | # ifdef _SIZE_T | |
224 | # define scm_sizet size_t | |
225 | # else | |
226 | # define scm_sizet unsigned int | |
227 | # endif /* def _SIZE_T */ | |
228 | #endif /* def STDC_HEADERS */ | |
229 | ||
230 | \f | |
231 | ||
232 | #include "libguile/tags.h" | |
0f2d19dd JB |
233 | |
234 | \f | |
235 | #ifdef vms | |
236 | # ifndef CHEAP_CONTINUATIONS | |
237 | typedef int jmp_buf[17]; | |
238 | extern int setjump(jmp_buf env); | |
239 | extern int longjump(jmp_buf env, int ret); | |
240 | # define setjmp setjump | |
241 | # define longjmp longjump | |
242 | # else | |
243 | # include <setjmp.h> | |
244 | # endif | |
245 | #else /* ndef vms */ | |
246 | # ifdef _CRAY1 | |
247 | typedef int jmp_buf[112]; | |
248 | extern int setjump(jmp_buf env); | |
249 | extern int longjump(jmp_buf env, int ret); | |
250 | # define setjmp setjump | |
251 | # define longjmp longjump | |
252 | # else /* ndef _CRAY1 */ | |
253 | # include <setjmp.h> | |
254 | # endif /* ndef _CRAY1 */ | |
255 | #endif /* ndef vms */ | |
256 | ||
0f2d19dd JB |
257 | /* James Clark came up with this neat one instruction fix for |
258 | * continuations on the SPARC. It flushes the register windows so | |
259 | * that all the state of the process is contained in the stack. | |
260 | */ | |
261 | ||
262 | #ifdef sparc | |
263 | # define SCM_FLUSH_REGISTER_WINDOWS asm("ta 3") | |
264 | #else | |
265 | # define SCM_FLUSH_REGISTER_WINDOWS /* empty */ | |
266 | #endif | |
267 | ||
268 | /* If stack is not longword aligned then | |
269 | */ | |
270 | ||
271 | /* #define SHORT_ALIGN */ | |
272 | #ifdef THINK_C | |
273 | # define SHORT_ALIGN | |
274 | #endif | |
275 | #ifdef MSDOS | |
276 | # define SHORT_ALIGN | |
277 | #endif | |
278 | #ifdef atarist | |
279 | # define SHORT_ALIGN | |
280 | #endif | |
281 | ||
282 | #ifdef SHORT_ALIGN | |
283 | typedef short SCM_STACKITEM; | |
284 | #else | |
285 | typedef long SCM_STACKITEM; | |
286 | #endif | |
287 | \f | |
288 | ||
82339094 | 289 | #ifndef USE_THREADS |
25d3ee9d MD |
290 | #define SCM_THREAD_DEFER |
291 | #define SCM_THREAD_ALLOW | |
292 | #define SCM_THREAD_REDEFER | |
25d3ee9d | 293 | #define SCM_THREAD_SWITCHING_CODE |
82339094 MD |
294 | #endif |
295 | ||
9f0e55a6 | 296 | #ifdef GUILE_OLD_ASYNC_CLICK |
0f2d19dd | 297 | extern unsigned int scm_async_clock; |
82339094 | 298 | |
25d3ee9d | 299 | #define SCM_ASYNC_TICK \ |
bfc69694 | 300 | do { \ |
25d3ee9d MD |
301 | if (0 == --scm_async_clock) \ |
302 | scm_async_click (); \ | |
bfc69694 | 303 | } while(0) |
9f0e55a6 MD |
304 | #else |
305 | extern int scm_asyncs_pending_p; | |
306 | ||
307 | #define SCM_ASYNC_TICK /*fixme* should change names */ \ | |
308 | do { \ | |
309 | if (scm_asyncs_pending_p) \ | |
310 | scm_async_click (); \ | |
311 | } while (0) | |
312 | #endif | |
25d3ee9d | 313 | |
0f2d19dd JB |
314 | #ifdef SCM_CAREFUL_INTS |
315 | #define SCM_CHECK_NOT_DISABLED \ | |
316 | if (scm_ints_disabled) \ | |
317 | fputs("ints already disabled\n", stderr); \ | |
318 | ||
319 | #define SCM_CHECK_NOT_ENABLED \ | |
320 | if (!scm_ints_disabled) \ | |
321 | fputs("ints already enabled\n", stderr); \ | |
322 | ||
323 | #else | |
324 | #define SCM_CHECK_NOT_DISABLED | |
325 | #define SCM_CHECK_NOT_ENABLED | |
326 | #endif | |
327 | ||
328 | ||
8417b665 JB |
329 | /* Anthony Green writes: |
330 | When the compiler sees... | |
331 | DEFER_INTS; | |
332 | [critical code here] | |
333 | ALLOW_INTS; | |
334 | ...it doesn't actually promise to keep the critical code within the | |
335 | boundries of the DEFER/ALLOW_INTS instructions. It may very well | |
336 | schedule it outside of the magic defined in those macros. | |
337 | ||
338 | However, GCC's volatile asm feature forms a barrier over which code is | |
339 | never moved. So if you add... | |
35eec738 JB |
340 | asm (""); |
341 | ...to each of the DEFER_INTS and ALLOW_INTS macros, the critical | |
342 | code will always remain in place. asm's without inputs or outputs | |
343 | are implicitly volatile. */ | |
8417b665 | 344 | #ifdef __GNUC__ |
35eec738 | 345 | #define SCM_FENCE asm /* volatile */ ("") |
8417b665 JB |
346 | #else |
347 | #define SCM_FENCE | |
348 | #endif | |
349 | ||
0f2d19dd | 350 | #define SCM_DEFER_INTS \ |
bfc69694 | 351 | do { \ |
8417b665 | 352 | SCM_FENCE; \ |
0f2d19dd | 353 | SCM_CHECK_NOT_DISABLED; \ |
25d3ee9d | 354 | SCM_THREAD_DEFER; \ |
8417b665 | 355 | SCM_FENCE; \ |
0f2d19dd | 356 | scm_ints_disabled = 1; \ |
8417b665 | 357 | SCM_FENCE; \ |
bfc69694 | 358 | } while (0) |
0f2d19dd JB |
359 | |
360 | ||
361 | #define SCM_ALLOW_INTS_ONLY \ | |
bfc69694 | 362 | do { \ |
25d3ee9d | 363 | SCM_THREAD_ALLOW; \ |
0f2d19dd | 364 | scm_ints_disabled = 0; \ |
bfc69694 | 365 | } while (0) |
0f2d19dd JB |
366 | |
367 | ||
368 | #define SCM_ALLOW_INTS \ | |
bfc69694 | 369 | do { \ |
8417b665 | 370 | SCM_FENCE; \ |
0f2d19dd | 371 | SCM_CHECK_NOT_ENABLED; \ |
c72cc5fb MD |
372 | SCM_THREAD_SWITCHING_CODE; \ |
373 | SCM_FENCE; \ | |
0f2d19dd | 374 | scm_ints_disabled = 0; \ |
8417b665 JB |
375 | SCM_FENCE; \ |
376 | SCM_THREAD_ALLOW; \ | |
8417b665 | 377 | SCM_FENCE; \ |
bfc69694 | 378 | } while (0) |
0f2d19dd JB |
379 | |
380 | ||
381 | #define SCM_REDEFER_INTS \ | |
bfc69694 | 382 | do { \ |
c72cc5fb | 383 | SCM_FENCE; \ |
25d3ee9d | 384 | SCM_THREAD_REDEFER; \ |
0f2d19dd | 385 | ++scm_ints_disabled; \ |
c72cc5fb | 386 | SCM_FENCE; \ |
bfc69694 | 387 | } while (0) |
0f2d19dd JB |
388 | |
389 | ||
390 | #define SCM_REALLOW_INTS \ | |
bfc69694 | 391 | do { \ |
c72cc5fb | 392 | SCM_FENCE; \ |
c72cc5fb MD |
393 | SCM_THREAD_SWITCHING_CODE; \ |
394 | SCM_FENCE; \ | |
0f2d19dd | 395 | --scm_ints_disabled; \ |
c72cc5fb | 396 | SCM_FENCE; \ |
bfc69694 | 397 | } while (0) |
0f2d19dd JB |
398 | |
399 | ||
c72cc5fb | 400 | #define SCM_TICK \ |
bfc69694 | 401 | do { \ |
c72cc5fb MD |
402 | SCM_DEFER_INTS; \ |
403 | SCM_ALLOW_INTS; \ | |
cd911565 | 404 | SCM_ASYNC_TICK; \ |
bfc69694 | 405 | } while (0) |
0f2d19dd JB |
406 | |
407 | \f | |
408 | ||
f83e2737 MD |
409 | /* Classification of critical sections |
410 | * | |
411 | * When Guile moves to POSIX threads, it won't be possible to prevent | |
412 | * context switching. In fact, the whole idea of context switching is | |
413 | * bogus if threads are run by different processors. Therefore, we | |
414 | * must ultimately eliminate all critical sections or enforce them by | |
415 | * use of mutecis. | |
416 | * | |
417 | * All instances of SCM_DEFER_INTS and SCM_ALLOW_INTS should therefore | |
418 | * be classified and replaced by one of the delimiters below. If you | |
419 | * understand what this is all about, I'd like to encourage you to | |
420 | * help with this task. The set of classes below must of course be | |
421 | * incrementally augmented. | |
422 | * | |
423 | * MDJ 980419 <djurfeldt@nada.kth.se> | |
424 | */ | |
425 | ||
426 | /* A sections | |
427 | * | |
428 | * Allocation of a cell with type tag in the CAR. | |
429 | * | |
430 | * With POSIX threads, each thread will have a private pool of free | |
431 | * cells. Therefore, this type of section can be removed. But! It | |
432 | * is important that the CDR is initialized first (with the CAR still | |
433 | * indicating a free cell) so that we can guarantee a consistent heap | |
434 | * at all times. | |
435 | */ | |
436 | ||
437 | #ifdef SCM_POSIX_THREADS | |
438 | #define SCM_ENTER_A_SECTION | |
439 | #define SCM_EXIT_A_SECTION | |
440 | #else | |
441 | #define SCM_ENTER_A_SECTION SCM_DEFER_INTS | |
442 | #define SCM_EXIT_A_SECTION SCM_ALLOW_INTS | |
443 | #endif | |
444 | ||
445 | \f | |
446 | ||
0f2d19dd JB |
447 | /** SCM_ASSERT |
448 | ** | |
449 | **/ | |
450 | ||
451 | ||
452 | #ifdef SCM_RECKLESS | |
453 | #define SCM_ASSERT(_cond, _arg, _pos, _subr) | |
b6791b2e | 454 | #define SCM_ASSERT_TYPE(_cond, _arg, _pos, _subr) |
0f2d19dd JB |
455 | #define SCM_ASRTGO(_cond, _label) |
456 | #else | |
457 | #define SCM_ASSERT(_cond, _arg, _pos, _subr) \ | |
458 | if (!(_cond)) \ | |
459 | scm_wta(_arg, (char *)(_pos), _subr) | |
b6791b2e GB |
460 | #define SCM_ASSERT_TYPE(_cond, _arg, _pos, _subr, _msg) \ |
461 | if (!(_cond)) \ | |
462 | scm_wrong_type_arg_msg(_subr, _pos, _arg, _msg) | |
0f2d19dd JB |
463 | #define SCM_ASRTGO(_cond, _label) \ |
464 | if (!(_cond)) \ | |
465 | goto _label | |
466 | #endif | |
95b88819 | 467 | |
9de33deb MD |
468 | /* |
469 | * SCM_WTA_DISPATCH | |
470 | */ | |
471 | ||
451e591c DH |
472 | /* Dirk:FIXME:: In all of the SCM_WTA_DISPATCH_* macros it is assumed that |
473 | * 'gf' is zero if uninitialized. It would be cleaner if some valid SCM value | |
474 | * like SCM_BOOL_F or SCM_UNDEFINED was chosen. | |
475 | */ | |
476 | ||
b3c8a0f5 MD |
477 | extern SCM scm_call_generic_0 (SCM gf); |
478 | ||
479 | #define SCM_WTA_DISPATCH_0(gf, arg, pos, subr) \ | |
451e591c | 480 | return (SCM_UNPACK (gf) \ |
b3c8a0f5 MD |
481 | ? scm_call_generic_0 ((gf)) \ |
482 | : scm_wta ((arg), (char *) (pos), (subr))) | |
483 | #define SCM_GASSERT0(cond, gf, arg, pos, subr) \ | |
ff725a17 | 484 | if (!(cond)) SCM_WTA_DISPATCH_0((gf), (arg), (pos), (subr)) |
b3c8a0f5 | 485 | |
9de33deb MD |
486 | extern SCM scm_call_generic_1 (SCM gf, SCM a1); |
487 | ||
488 | #define SCM_WTA_DISPATCH_1(gf, a1, pos, subr) \ | |
451e591c | 489 | return (SCM_UNPACK (gf) \ |
9de33deb MD |
490 | ? scm_call_generic_1 ((gf), (a1)) \ |
491 | : scm_wta ((a1), (char *) (pos), (subr))) | |
492 | #define SCM_GASSERT1(cond, gf, a1, pos, subr) \ | |
493 | if (!(cond)) SCM_WTA_DISPATCH_1((gf), (a1), (pos), (subr)) | |
494 | ||
495 | extern SCM scm_call_generic_2 (SCM gf, SCM a1, SCM a2); | |
496 | ||
497 | #define SCM_WTA_DISPATCH_2(gf, a1, a2, pos, subr) \ | |
451e591c | 498 | return (SCM_UNPACK (gf) \ |
9de33deb MD |
499 | ? scm_call_generic_2 ((gf), (a1), (a2)) \ |
500 | : scm_wta ((pos) == SCM_ARG1 ? (a1) : (a2), (char *) (pos), (subr))) | |
501 | #define SCM_GASSERT2(cond, gf, a1, a2, pos, subr) \ | |
502 | if (!(cond)) SCM_WTA_DISPATCH_2((gf), (a1), (a2), (pos), (subr)) | |
503 | ||
89c358b1 MD |
504 | extern SCM scm_apply_generic (SCM gf, SCM args); |
505 | ||
506 | #define SCM_WTA_DISPATCH_n(gf, args, pos, subr) \ | |
451e591c | 507 | return (SCM_UNPACK (gf) \ |
89c358b1 MD |
508 | ? scm_apply_generic ((gf), (args)) \ |
509 | : scm_wta (scm_list_ref ((args), SCM_MAKINUM ((pos) - 1)), \ | |
510 | (char *) (pos), \ | |
511 | (subr))) | |
512 | #define SCM_GASSERTn(cond, gf, args, pos, subr) \ | |
513 | if (!(cond)) SCM_WTA_DISPATCH_n((gf), (args), (pos), (subr)) | |
514 | ||
c751e5e3 GB |
515 | #ifndef SCM_MAGIC_SNARFER |
516 | /* Let these macros pass through if | |
517 | we are snarfing; thus we can tell the | |
518 | difference between the use of an actual | |
519 | number vs. the use of one of these macros -- | |
f5421cfc | 520 | actual numbers in SCM_VALIDATE_* and SCM_ASSERT |
c751e5e3 GB |
521 | constructs must match the formal argument name, |
522 | but using SCM_ARG* avoids the test */ | |
523 | ||
0f2d19dd JB |
524 | #define SCM_ARGn 0 |
525 | #define SCM_ARG1 1 | |
526 | #define SCM_ARG2 2 | |
527 | #define SCM_ARG3 3 | |
528 | #define SCM_ARG4 4 | |
529 | #define SCM_ARG5 5 | |
1146b6cd GH |
530 | #define SCM_ARG6 6 |
531 | #define SCM_ARG7 7 | |
f5bf2977 | 532 | /* #define SCM_ARGERR(X) ((X) < SCM_WNA \ |
0f2d19dd JB |
533 | ? (char *)(X) \ |
534 | : "wrong type argument") | |
f5bf2977 | 535 | */ |
0f2d19dd JB |
536 | |
537 | /* Following must match entry indexes in scm_errmsgs[]. | |
538 | * Also, SCM_WNA must follow the last SCM_ARGn in sequence. | |
539 | */ | |
540 | #define SCM_WNA 8 | |
e1724d20 | 541 | /* #define SCM_OVSCM_FLOW 9 */ |
0f2d19dd JB |
542 | #define SCM_OUTOFRANGE 10 |
543 | #define SCM_NALLOC 11 | |
f5bf2977 GH |
544 | /* #define SCM_STACK_OVFLOW 12 */ |
545 | /* #define SCM_EXIT 13 */ | |
0f2d19dd | 546 | |
c751e5e3 | 547 | #endif /* SCM_MAGIC_SNARFER */ |
0f2d19dd JB |
548 | |
549 | /* (...still matching scm_errmsgs) These | |
550 | * are signals. Signals may become errors | |
551 | * but are distinguished because they first | |
552 | * try to invoke a handler that can resume | |
553 | * the interrupted routine. | |
554 | */ | |
555 | #define SCM_HUP_SIGNAL 14 | |
556 | #define SCM_INT_SIGNAL 15 | |
557 | #define SCM_FPE_SIGNAL 16 | |
558 | #define SCM_BUS_SIGNAL 17 | |
559 | #define SCM_SEGV_SIGNAL 18 | |
560 | #define SCM_ALRM_SIGNAL 19 | |
561 | #define SCM_GC_SIGNAL 20 | |
562 | #define SCM_TICK_SIGNAL 21 | |
563 | ||
564 | #define SCM_SIG_ORD(X) ((X) - SCM_HUP_SIGNAL) | |
565 | #define SCM_ORD_SIG(X) ((X) + SCM_HUP_SIGNAL) | |
566 | #define SCM_NUM_SIGS (SCM_SIG_ORD (SCM_TICK_SIGNAL) + 1) | |
567 | ||
82339094 | 568 | #if 0 |
0f2d19dd JB |
569 | struct errdesc |
570 | { | |
571 | char *msg; | |
572 | char *s_response; | |
573 | short parent_err; | |
574 | }; | |
575 | ||
576 | ||
577 | extern struct errdesc scm_errmsgs[]; | |
82339094 | 578 | #endif |
0f2d19dd JB |
579 | |
580 | \f | |
581 | ||
582 | /* SCM_EXIT_SUCCESS is the default code to return from SCM if no errors | |
583 | * were encountered. SCM_EXIT_FAILURE is the default code to return from | |
584 | * SCM if errors were encountered. The return code can be explicitly | |
585 | * specified in a SCM program with (scm_quit <n>). | |
586 | */ | |
587 | ||
588 | #ifndef SCM_EXIT_SUCCESS | |
589 | #ifdef vms | |
590 | #define SCM_EXIT_SUCCESS 1 | |
591 | #else | |
592 | #define SCM_EXIT_SUCCESS 0 | |
593 | #endif /* def vms */ | |
594 | #endif /* ndef SCM_EXIT_SUCCESS */ | |
595 | #ifndef SCM_EXIT_FAILURE | |
596 | #ifdef vms | |
597 | #define SCM_EXIT_FAILURE 2 | |
598 | #else | |
599 | #define SCM_EXIT_FAILURE 1 | |
600 | #endif /* def vms */ | |
601 | #endif /* ndef SCM_EXIT_FAILURE */ | |
602 | ||
603 | ||
604 | ||
605 | \f | |
0f2d19dd JB |
606 | |
607 | #endif /* __SCMH */ | |
89e00824 ML |
608 | |
609 | /* | |
610 | Local Variables: | |
611 | c-file-style: "gnu" | |
612 | End: | |
613 | */ |