scm_i_make_continuation takes vm and vm_cont args explicitly
[bpt/guile.git] / libguile / continuations.h
1 /* classes: h_files */
2
3 #ifndef SCM_CONTINUATIONS_H
4 #define SCM_CONTINUATIONS_H
5
6 /* Copyright (C) 1995,1996,2000,2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24 \f
25
26 #include "libguile/__scm.h"
27
28 #ifdef __ia64__
29 #include <signal.h>
30 #include <ucontext.h>
31 #endif /* __ia64__ */
32 \f
33
34 #define SCM_CONTINUATIONP(x) \
35 (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_CONTINUATION (x))
36
37 /* a continuation SCM is a non-immediate pointing to a heap cell with:
38 word 0: bits 0-15: smob type tag: scm_tc16_continuation.
39 bits 16-31: unused.
40 word 1: malloc block containing an scm_t_contregs structure with a
41 tail array of SCM_STACKITEM. the size of the array is stored
42 in the num_stack_items field of the structure.
43 */
44
45 typedef struct
46 {
47 SCM throw_value;
48 scm_i_jmp_buf jmpbuf;
49 SCM dynenv;
50 #ifdef __ia64__
51 void *backing_store;
52 unsigned long backing_store_size;
53 #endif /* __ia64__ */
54 size_t num_stack_items; /* size of the saved stack. */
55 SCM root; /* continuation root identifier. */
56 SCM vm; /* vm */
57 SCM vm_cont; /* vm's stack and regs */
58
59 /* The offset from the live stack location to this copy. This is
60 used to adjust pointers from within the copied stack to the stack
61 itself.
62
63 Thus, when you read a pointer from the copied stack that points
64 into the live stack, you need to add OFFSET so that it points
65 into the copy.
66 */
67 scm_t_ptrdiff offset;
68
69 SCM_STACKITEM stack[1]; /* copied stack of size num_stack_items. */
70 } scm_t_contregs;
71
72
73 \f
74
75 SCM_INTERNAL SCM scm_i_make_continuation (int *first, SCM vm, SCM vm_cont);
76 SCM_INTERNAL SCM scm_i_call_with_current_continuation (SCM proc);
77 SCM_INTERNAL SCM scm_i_continuation_to_frame (SCM cont);
78 SCM_INTERNAL void scm_i_continuation_call (SCM cont, size_t n, SCM *argv);
79
80 SCM_API void *scm_c_with_continuation_barrier (void *(*func)(void*), void *);
81 SCM_API SCM scm_with_continuation_barrier (SCM proc);
82
83 SCM_INTERNAL SCM
84 scm_i_with_continuation_barrier (scm_t_catch_body body,
85 void *body_data,
86 scm_t_catch_handler handler,
87 void *handler_data,
88 scm_t_catch_handler pre_unwind_handler,
89 void *pre_unwind_handler_data);
90
91 SCM_INTERNAL void scm_init_continuations (void);
92
93 #endif /* SCM_CONTINUATIONS_H */
94
95 /*
96 Local Variables:
97 c-file-style: "gnu"
98 End:
99 */