* configure.in: If we can find the library for tcl7.5, build
[bpt/guile.git] / libguile / __scm.h
CommitLineData
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
107/* Random options (net yet supported or in final form). */
108
109#undef DEBUG_EXTENSIONS
110#undef READER_EXTENSIONS
111#undef SCM_STACK_LIMIT 20000
112#undef NO_CEVAL_STACK_CHECK
113#undef LONGLONGS
114
115/* Some auto-generated .h files contain unused prototypes
116 * that need these typedefs.
117 */
118typedef long long_long;
119typedef unsigned long ulong_long;
120
121
122\f
123
124/* Define
125 *
126 * SCM_CHAR_SCM_CODE_LIMIT == UCHAR_MAX + 1
127 * SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2)
128 * SCM_MOST_NEGATIVE_FIXNUM == SCM_SRS((long)LONG_MIN, 2)
129 */
130
131#ifdef HAVE_LIMITSH
132# include <limits.h>
133# ifdef UCHAR_MAX
134# define SCM_CHAR_SCM_CODE_LIMIT (UCHAR_MAX+1L)
135# else
136# define SCM_CHAR_SCM_CODE_LIMIT 256L
137# endif /* def UCHAR_MAX */
138# define SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2)
139# ifdef _UNICOS /* Stupid cray bug */
140# define SCM_MOST_NEGATIVE_FIXNUM ((long)LONG_MIN/4)
141# else
142# define SCM_MOST_NEGATIVE_FIXNUM SCM_SRS((long)LONG_MIN, 2)
143# endif /* UNICOS */
144#else
145# define SCM_CHAR_SCM_CODE_LIMIT 256L
146# define SCM_MOST_POSITIVE_FIXNUM ((long)((unsigned long)~0L>>3))
147# if (0 != ~0)
148# define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1)
149# else
150# define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM)
151# endif /* (0 != ~0) */
152#endif /* def HAVE_LIMITSH */
153\f
154
155#include <scmconfig.h>
156#include "tags.h"
157
158\f
159#ifdef vms
160# ifndef CHEAP_CONTINUATIONS
161 typedef int jmp_buf[17];
162 extern int setjump(jmp_buf env);
163 extern int longjump(jmp_buf env, int ret);
164# define setjmp setjump
165# define longjmp longjump
166# else
167# include <setjmp.h>
168# endif
169#else /* ndef vms */
170# ifdef _CRAY1
171 typedef int jmp_buf[112];
172 extern int setjump(jmp_buf env);
173 extern int longjump(jmp_buf env, int ret);
174# define setjmp setjump
175# define longjmp longjump
176# else /* ndef _CRAY1 */
177# include <setjmp.h>
178# endif /* ndef _CRAY1 */
179#endif /* ndef vms */
180
0f2d19dd
JB
181/* James Clark came up with this neat one instruction fix for
182 * continuations on the SPARC. It flushes the register windows so
183 * that all the state of the process is contained in the stack.
184 */
185
186#ifdef sparc
187# define SCM_FLUSH_REGISTER_WINDOWS asm("ta 3")
188#else
189# define SCM_FLUSH_REGISTER_WINDOWS /* empty */
190#endif
191
192/* If stack is not longword aligned then
193 */
194
195/* #define SHORT_ALIGN */
196#ifdef THINK_C
197# define SHORT_ALIGN
198#endif
199#ifdef MSDOS
200# define SHORT_ALIGN
201#endif
202#ifdef atarist
203# define SHORT_ALIGN
204#endif
205
206#ifdef SHORT_ALIGN
207typedef short SCM_STACKITEM;
208#else
209typedef long SCM_STACKITEM;
210#endif
211\f
212
213extern unsigned int scm_async_clock;
214#define SCM_ASYNC_TICK if (0 == --scm_async_clock) scm_async_click ()
215
216#ifdef SCM_CAREFUL_INTS
217#define SCM_CHECK_NOT_DISABLED \
218 if (scm_ints_disabled) \
219 fputs("ints already disabled\n", stderr); \
220
221#define SCM_CHECK_NOT_ENABLED \
222 if (!scm_ints_disabled) \
223 fputs("ints already enabled\n", stderr); \
224
225#else
226#define SCM_CHECK_NOT_DISABLED
227#define SCM_CHECK_NOT_ENABLED
228#endif
229
230
231#define SCM_DEFER_INTS \
232{ \
233 SCM_CHECK_NOT_DISABLED; \
234 scm_ints_disabled = 1; \
235} \
236
237
238#define SCM_ALLOW_INTS_ONLY \
239{ \
240 scm_ints_disabled = 0; \
241} \
242
243
244#define SCM_ALLOW_INTS \
245{ \
246 SCM_CHECK_NOT_ENABLED; \
247 scm_ints_disabled = 0; \
248 SCM_ASYNC_TICK; \
249} \
250
251
252#define SCM_REDEFER_INTS \
253{ \
254 ++scm_ints_disabled; \
255} \
256
257
258#define SCM_REALLOW_INTS \
259{ \
260 --scm_ints_disabled; \
261 if (!scm_ints_disabled) \
262 SCM_ASYNC_TICK; \
263} \
264
265
266
267\f
268
269/** SCM_ASSERT
270 **
271 **/
272
273
274#ifdef SCM_RECKLESS
275#define SCM_ASSERT(_cond, _arg, _pos, _subr)
276#define SCM_ASRTGO(_cond, _label)
277#else
278#define SCM_ASSERT(_cond, _arg, _pos, _subr) \
279 if (!(_cond)) \
280 scm_wta(_arg, (char *)(_pos), _subr)
281#define SCM_ASRTGO(_cond, _label) \
282 if (!(_cond)) \
283 goto _label
284#endif
95b88819 285
02b754d3
GH
286#define SCM_SYSERROR(_subr) \
287 scm_everr (SCM_UNDEFINED, SCM_EOL, SCM_UNDEFINED, \
288 strerror (errno), _subr)
289
290 /* equivalent to:
291 scm_throw (system_error_sym, \
292 scm_listify (scm_makfrom0str (strerror (errno)), \
293 scm_makfrom0str (_subr), \
294 SCM_UNDEFINED));
295 */
95b88819
GH
296#ifdef ENOSYS
297# define SCM_SYSMISSING(_subr) \
298 scm_everr (SCM_UNDEFINED, SCM_EOL, SCM_UNDEFINED, \
299 strerror (ENOSYS), _subr)
300#else
301# define SCM_SYSMISSING(_subr) \
302 scm_everr (SCM_UNDEFINED, SCM_EOL, SCM_UNDEFINED, \
303 "missing function, even ENOSYS is missing", _subr)
304#endif
0f2d19dd
JB
305#define SCM_ARGn 0
306#define SCM_ARG1 1
307#define SCM_ARG2 2
308#define SCM_ARG3 3
309#define SCM_ARG4 4
310#define SCM_ARG5 5
311#define SCM_ARG6 6
312#define SCM_ARG7 7
313#define SCM_ARGERR(X) ((X) < SCM_WNA \
314 ? (char *)(X) \
315 : "wrong type argument")
316
317/* Following must match entry indexes in scm_errmsgs[].
318 * Also, SCM_WNA must follow the last SCM_ARGn in sequence.
319 */
320#define SCM_WNA 8
321#define SCM_OVSCM_FLOW 9
322#define SCM_OUTOFRANGE 10
323#define SCM_NALLOC 11
324#define SCM_STACK_SCM_OVSCM_FLOW 12
325#define SCM_EXIT 13
326
327
328/* (...still matching scm_errmsgs) These
329 * are signals. Signals may become errors
330 * but are distinguished because they first
331 * try to invoke a handler that can resume
332 * the interrupted routine.
333 */
334#define SCM_HUP_SIGNAL 14
335#define SCM_INT_SIGNAL 15
336#define SCM_FPE_SIGNAL 16
337#define SCM_BUS_SIGNAL 17
338#define SCM_SEGV_SIGNAL 18
339#define SCM_ALRM_SIGNAL 19
340#define SCM_GC_SIGNAL 20
341#define SCM_TICK_SIGNAL 21
342
343#define SCM_SIG_ORD(X) ((X) - SCM_HUP_SIGNAL)
344#define SCM_ORD_SIG(X) ((X) + SCM_HUP_SIGNAL)
345#define SCM_NUM_SIGS (SCM_SIG_ORD (SCM_TICK_SIGNAL) + 1)
346
347struct errdesc
348{
349 char *msg;
350 char *s_response;
351 short parent_err;
352};
353
354
355extern struct errdesc scm_errmsgs[];
356
357\f
358
359/* SCM_EXIT_SUCCESS is the default code to return from SCM if no errors
360 * were encountered. SCM_EXIT_FAILURE is the default code to return from
361 * SCM if errors were encountered. The return code can be explicitly
362 * specified in a SCM program with (scm_quit <n>).
363 */
364
365#ifndef SCM_EXIT_SUCCESS
366#ifdef vms
367#define SCM_EXIT_SUCCESS 1
368#else
369#define SCM_EXIT_SUCCESS 0
370#endif /* def vms */
371#endif /* ndef SCM_EXIT_SUCCESS */
372#ifndef SCM_EXIT_FAILURE
373#ifdef vms
374#define SCM_EXIT_FAILURE 2
375#else
376#define SCM_EXIT_FAILURE 1
377#endif /* def vms */
378#endif /* ndef SCM_EXIT_FAILURE */
379
380
381
382\f
383#ifdef __STDC__
384
385#else /* STDC */
386
387#endif /* STDC */
388
389
390#endif /* __SCMH */