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