Lots of fixes to make guile (at some time) compile with strict typing.
[bpt/guile.git] / libguile / root.h
CommitLineData
0f2d19dd
JB
1/* classes: h_files */
2
3#ifndef ROOTH
4#define ROOTH
5
7dc6e754 6/* Copyright (C) 1996,1998 Free Software Foundation, Inc.
0f2d19dd
JB
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this software; see the file COPYING. If not, write to
82892bed
JB
20 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307 USA
0f2d19dd
JB
22 *
23 * As a special exception, the Free Software Foundation gives permission
24 * for additional uses of the text contained in its release of GUILE.
25 *
26 * The exception is that, if you link the GUILE library with other files
27 * to produce an executable, this does not by itself cause the
28 * resulting executable to be covered by the GNU General Public License.
29 * Your use of that executable is in no way restricted on account of
30 * linking the GUILE library code into it.
31 *
32 * This exception does not however invalidate any other reasons why
33 * the executable file might be covered by the GNU General Public License.
34 *
35 * This exception applies only to the code released by the
36 * Free Software Foundation under the name GUILE. If you copy
37 * code from other Free Software Foundation releases into a copy of
38 * GUILE, as the General Public License permits, the exception does
39 * not apply to the code that you add in this way. To avoid misleading
40 * anyone as to the status of such modified files, you must delete
41 * this exception notice from them.
42 *
43 * If you write modifications of your own for GUILE, it is your choice
44 * whether to permit this exception to apply to your modifications.
82892bed 45 * If you do not wish that, delete this exception notice. */
d3a6bc94
GB
46
47/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
48 gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
0f2d19dd
JB
49\f
50
51\f
52
b4309c3c 53#include "libguile/__scm.h"
033c7f3d 54#include "libguile/debug.h"
e71575d9 55#include "libguile/throw.h"
0f2d19dd
JB
56
57\f
58
59#define scm_flo0 scm_sys_protects[0]
60#define scm_listofnull scm_sys_protects[1]
61#define scm_undefineds scm_sys_protects[2]
62#define scm_nullvect scm_sys_protects[3]
63#define scm_nullstr scm_sys_protects[4]
64#define scm_symhash scm_sys_protects[5]
65#define scm_weak_symhash scm_sys_protects[6]
66#define scm_symhash_vars scm_sys_protects[7]
0e76bf66 67#define scm_keyword_obarray scm_sys_protects[8]
0f2d19dd
JB
68#define scm_type_obj_list scm_sys_protects[9]
69#define scm_first_type scm_sys_protects[10]
70#define scm_stand_in_procs scm_sys_protects[11]
71#define scm_object_whash scm_sys_protects[12]
72#define scm_permobjs scm_sys_protects[13]
73#define scm_asyncs scm_sys_protects[14]
ef290276 74#define scm_protects scm_sys_protects[15]
615aec77 75#ifdef DEBUG_EXTENSIONS
ef290276
JB
76#define scm_source_whash scm_sys_protects[16]
77#define SCM_NUM_PROTECTS 17
615aec77 78#else
ef290276 79#define SCM_NUM_PROTECTS 16
615aec77 80#endif
0f2d19dd
JB
81
82extern SCM scm_sys_protects[];
83
84\f
85
010afa35
MD
86extern long scm_tc16_root;
87
d3a6bc94 88#define SCM_ROOTP(obj) (SCM_NIMP(obj) && (scm_tc16_root == SCM_TYP16 (obj)))
54778cd3 89#define SCM_ROOT_STATE(root) ((scm_root_state *) SCM_CELL_WORD_1 (root))
010afa35
MD
90
91typedef struct scm_root_state
0f2d19dd
JB
92{
93 SCM_STACKITEM * stack_base;
94 jmp_buf save_regs_gc_mark;
95 int errjmp_bad;
96
97 SCM rootcont;
98 SCM dynwinds;
99 SCM continuation_stack;
100 SCM continuation_stack_ptr;
033c7f3d
MD
101#ifdef DEBUG_EXTENSIONS
102 /* It is very inefficient to have this variable in the root state. */
103 scm_debug_frame *last_debug_frame;
104#endif
7b4e5a7a 105
0f2d19dd
JB
106 SCM progargs; /* vestigial */
107 SCM exitval; /* vestigial */
108
109 SCM cur_inp;
110 SCM cur_outp;
111 SCM cur_errp;
112 SCM def_inp;
113 SCM def_outp;
114 SCM def_errp;
903073d5 115 SCM cur_loadp;
0f2d19dd 116
7b4e5a7a
MV
117 SCM fluids;
118
0f2d19dd 119 SCM system_transformer;
dc19d1d2 120 SCM top_level_lookup_closure_var;
010afa35
MD
121
122 SCM handle; /* The root object for this root state */
123 SCM parent; /* The parent root object */
124} scm_root_state;
0f2d19dd
JB
125
126#define scm_stack_base (scm_root->stack_base)
127#define scm_save_regs_gc_mark (scm_root->save_regs_gc_mark)
128#define scm_errjmp_bad (scm_root->errjmp_bad)
129
130#define scm_rootcont (scm_root->rootcont)
131#define scm_dynwinds (scm_root->dynwinds)
132#define scm_continuation_stack (scm_root->continuation_stack)
133#define scm_continuation_stack_ptr (scm_root->continuation_stack_ptr)
134#define scm_progargs (scm_root->progargs)
033c7f3d
MD
135#ifdef USE_THREADS
136#define scm_last_debug_frame (scm_root->last_debug_frame)
137#endif
0f2d19dd
JB
138#define scm_exitval (scm_root->exitval)
139#define scm_cur_inp (scm_root->cur_inp)
140#define scm_cur_outp (scm_root->cur_outp)
141#define scm_cur_errp (scm_root->cur_errp)
142#define scm_def_inp (scm_root->def_inp)
143#define scm_def_outp (scm_root->def_outp)
144#define scm_def_errp (scm_root->def_errp)
903073d5 145#define scm_cur_loadp (scm_root->cur_loadp)
dc19d1d2
JB
146#define scm_top_level_lookup_closure_var \
147 (scm_root->top_level_lookup_closure_var)
0f2d19dd 148#define scm_system_transformer (scm_root->system_transformer)
5aab5d96 149
010afa35 150#ifdef USE_THREADS
f15347a0
MD
151#define scm_root ((scm_root_state *) SCM_THREAD_LOCAL_DATA)
152#define scm_set_root(new_root) SCM_SET_THREAD_LOCAL_DATA (new_root)
010afa35 153#else /* USE_THREADS */
010afa35
MD
154extern struct scm_root_state *scm_root;
155#define scm_set_root(new_root) (scm_root = (new_root))
010afa35 156#endif /* USE_THREADS */
0f2d19dd 157
010afa35 158\f
0f2d19dd 159
7866a09b
GB
160extern SCM scm_make_root (SCM parent);
161extern SCM scm_internal_cwdr (scm_catch_body_t body,
162 void *body_data,
163 scm_catch_handler_t handler,
164 void *handler_data,
165 SCM_STACKITEM *stack_start);
166extern SCM scm_call_with_dynamic_root (SCM thunk, SCM handler);
167extern SCM scm_dynamic_root (void);
168extern SCM scm_apply_with_dynamic_root (SCM proc, SCM a1, SCM args, SCM handler);
169extern SCM scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(), void * closure);
170extern void scm_init_root (void);
0f2d19dd
JB
171
172#endif /* ROOTH */
89e00824
ML
173
174/*
175 Local Variables:
176 c-file-style: "gnu"
177 End:
178*/