6 /* Copyright (C) 1996,1998,2000,2001 Free Software Foundation, Inc.
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)
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.
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
20 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307 USA
23 * As a special exception, the Free Software Foundation gives permission
24 * for additional uses of the text contained in its release of GUILE.
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.
32 * This exception does not however invalidate any other reasons why
33 * the executable file might be covered by the GNU General Public License.
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.
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.
45 * If you do not wish that, delete this exception notice. */
49 #include "libguile/__scm.h"
50 #include "libguile/debug.h"
51 #include "libguile/throw.h"
55 #define scm_flo0 scm_sys_protects[0]
56 #define scm_listofnull scm_sys_protects[1]
57 #define scm_undefineds scm_sys_protects[2]
58 #define scm_nullvect scm_sys_protects[3]
59 #define scm_nullstr scm_sys_protects[4]
60 #define scm_keyword_obarray scm_sys_protects[5]
61 #define scm_stand_in_procs scm_sys_protects[6]
62 #define scm_object_whash scm_sys_protects[7]
63 #define scm_permobjs scm_sys_protects[8]
64 #define scm_asyncs scm_sys_protects[9]
65 #define scm_protects scm_sys_protects[10]
66 #define scm_properties_whash scm_sys_protects[11]
67 #define scm_gc_registered_roots scm_sys_protects[12]
68 #ifdef DEBUG_EXTENSIONS
69 #define scm_source_whash scm_sys_protects[13]
70 #define SCM_NUM_PROTECTS 14
72 #define SCM_NUM_PROTECTS 13
75 SCM_API SCM scm_sys_protects
[];
79 SCM_API scm_t_bits scm_tc16_root
;
81 #define SCM_ROOTP(obj) SCM_TYP16_PREDICATE (scm_tc16_root, obj)
82 #define SCM_ROOT_STATE(root) ((scm_root_state *) SCM_CELL_WORD_1 (root))
84 typedef struct scm_root_state
86 SCM_STACKITEM
* stack_base
;
87 jmp_buf save_regs_gc_mark
;
92 #ifdef DEBUG_EXTENSIONS
93 /* It is very inefficient to have this variable in the root state. */
94 scm_t_debug_frame
*last_debug_frame
;
97 SCM progargs
; /* vestigial */
98 SCM exitval
; /* vestigial */
107 SCM handle
; /* The root object for this root state */
108 SCM parent
; /* The parent root object */
111 #define scm_stack_base (scm_root->stack_base)
112 #define scm_save_regs_gc_mark (scm_root->save_regs_gc_mark)
113 #define scm_errjmp_bad (scm_root->errjmp_bad)
115 #define scm_rootcont (scm_root->rootcont)
116 #define scm_dynwinds (scm_root->dynwinds)
117 #define scm_progargs (scm_root->progargs)
119 #define scm_last_debug_frame (scm_root->last_debug_frame)
121 #define scm_exitval (scm_root->exitval)
122 #define scm_cur_inp (scm_root->cur_inp)
123 #define scm_cur_outp (scm_root->cur_outp)
124 #define scm_cur_errp (scm_root->cur_errp)
125 #define scm_cur_loadp (scm_root->cur_loadp)
128 #define scm_root ((scm_root_state *) SCM_THREAD_LOCAL_DATA)
129 #define scm_set_root(new_root) SCM_SET_THREAD_LOCAL_DATA (new_root)
130 #else /* USE_THREADS */
131 SCM_API
struct scm_root_state
*scm_root
;
132 #define scm_set_root(new_root) (scm_root = (new_root))
133 #endif /* USE_THREADS */
137 SCM_API SCM
scm_make_root (SCM parent
);
138 SCM_API SCM
scm_internal_cwdr (scm_t_catch_body body
,
140 scm_t_catch_handler handler
,
142 SCM_STACKITEM
*stack_start
);
143 SCM_API SCM
scm_call_with_dynamic_root (SCM thunk
, SCM handler
);
144 SCM_API SCM
scm_dynamic_root (void);
145 SCM_API SCM
scm_apply_with_dynamic_root (SCM proc
, SCM a1
, SCM args
, SCM handler
);
146 SCM_API
void scm_init_root (void);
148 #endif /* SCM_ROOT_H */