Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
b29058ff DH |
3 | #ifndef SCM_CONTINUATIONS_H |
4 | #define SCM_CONTINUATIONS_H | |
5 | ||
1d1cae0e | 6 | /* Copyright (C) 1995,1996,2000,2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. |
b29058ff | 7 | * |
73be1d9e | 8 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
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. | |
b29058ff | 12 | * |
53befeb7 NJ |
13 | * This library is distributed in the hope that it will be useful, but |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
b29058ff | 17 | * |
73be1d9e MV |
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 | |
53befeb7 NJ |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
21 | * 02110-1301 USA | |
73be1d9e | 22 | */ |
b29058ff | 23 | |
0f2d19dd | 24 | \f |
b29058ff | 25 | |
b4309c3c | 26 | #include "libguile/__scm.h" |
0f2d19dd | 27 | |
766c5eaf | 28 | #ifdef __ia64__ |
6a535440 | 29 | #include <signal.h> |
78b6566e | 30 | #include <ucontext.h> |
87855fa2 | 31 | #endif /* __ia64__ */ |
0f2d19dd JB |
32 | \f |
33 | ||
1d1cae0e AW |
34 | #define SCM_CONTINUATIONP(x) \ |
35 | (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_CONTINUATION (x)) | |
36 | ||
5f144b10 | 37 | /* a continuation SCM is a non-immediate pointing to a heap cell with: |
2dbec7b5 GH |
38 | word 0: bits 0-15: smob type tag: scm_tc16_continuation. |
39 | bits 16-31: unused. | |
92c2555f | 40 | word 1: malloc block containing an scm_t_contregs structure with a |
5f144b10 GH |
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 | ||
0f2d19dd JB |
45 | typedef struct |
46 | { | |
a4dbe1ac | 47 | scm_i_jmp_buf jmpbuf; |
0f2d19dd | 48 | SCM dynenv; |
766c5eaf | 49 | #ifdef __ia64__ |
766c5eaf RB |
50 | void *backing_store; |
51 | unsigned long backing_store_size; | |
52 | #endif /* __ia64__ */ | |
c014a02e | 53 | size_t num_stack_items; /* size of the saved stack. */ |
9de87eea | 54 | SCM root; /* continuation root identifier. */ |
269479e3 AW |
55 | SCM vm; /* vm */ |
56 | SCM vm_cont; /* vm's stack and regs */ | |
0f2d19dd | 57 | |
9de87eea | 58 | /* The offset from the live stack location to this copy. This is |
5c5c27dc MV |
59 | used to adjust pointers from within the copied stack to the stack |
60 | itself. | |
61 | ||
62 | Thus, when you read a pointer from the copied stack that points | |
63 | into the live stack, you need to add OFFSET so that it points | |
64 | into the copy. | |
65 | */ | |
66 | scm_t_ptrdiff offset; | |
67 | ||
5f144b10 | 68 | SCM_STACKITEM stack[1]; /* copied stack of size num_stack_items. */ |
92c2555f | 69 | } scm_t_contregs; |
1be6b49c | 70 | |
0f2d19dd JB |
71 | |
72 | \f | |
73 | ||
269479e3 | 74 | SCM_INTERNAL SCM scm_i_make_continuation (int *first, SCM vm, SCM vm_cont); |
d8873dfe AW |
75 | SCM_INTERNAL void scm_i_check_continuation (SCM cont); |
76 | SCM_INTERNAL void scm_i_reinstate_continuation (SCM cont); | |
77 | ||
babfc7b2 | 78 | SCM_INTERNAL SCM scm_i_call_with_current_continuation (SCM proc); |
d8873dfe | 79 | |
1d1cae0e | 80 | SCM_INTERNAL SCM scm_i_continuation_to_frame (SCM cont); |
d8873dfe AW |
81 | SCM_INTERNAL SCM scm_i_contregs_vm (SCM contregs); |
82 | SCM_INTERNAL SCM scm_i_contregs_vm_cont (SCM contregs); | |
9de87eea MV |
83 | |
84 | SCM_API void *scm_c_with_continuation_barrier (void *(*func)(void*), void *); | |
85 | SCM_API SCM scm_with_continuation_barrier (SCM proc); | |
86 | ||
102dbb6f LC |
87 | SCM_INTERNAL SCM |
88 | scm_i_with_continuation_barrier (scm_t_catch_body body, | |
89 | void *body_data, | |
90 | scm_t_catch_handler handler, | |
91 | void *handler_data, | |
92 | scm_t_catch_handler pre_unwind_handler, | |
93 | void *pre_unwind_handler_data); | |
9de87eea | 94 | |
102dbb6f | 95 | SCM_INTERNAL void scm_init_continuations (void); |
0f2d19dd | 96 | |
b29058ff | 97 | #endif /* SCM_CONTINUATIONS_H */ |
89e00824 ML |
98 | |
99 | /* | |
100 | Local Variables: | |
101 | c-file-style: "gnu" | |
102 | End: | |
103 | */ |