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