make scm_make_continuation internal
[bpt/guile.git] / libguile / continuations.h
CommitLineData
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
45typedef struct
46{
47 SCM throw_value;
a4dbe1ac 48 scm_i_jmp_buf jmpbuf;
0f2d19dd 49 SCM dynenv;
766c5eaf 50#ifdef __ia64__
766c5eaf
RB
51 void *backing_store;
52 unsigned long backing_store_size;
53#endif /* __ia64__ */
c014a02e 54 size_t num_stack_items; /* size of the saved stack. */
9de87eea 55 SCM root; /* continuation root identifier. */
bfffd258 56 SCM vm_conts; /* vm continuations (they use separate stacks) */
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
997659f8 74SCM_INTERNAL SCM scm_i_make_continuation (int *first);
babfc7b2 75SCM_INTERNAL SCM scm_i_call_with_current_continuation (SCM proc);
1d1cae0e
AW
76SCM_INTERNAL SCM scm_i_continuation_to_frame (SCM cont);
77SCM_INTERNAL void scm_i_continuation_call (SCM cont, size_t n, SCM *argv);
9de87eea
MV
78
79SCM_API void *scm_c_with_continuation_barrier (void *(*func)(void*), void *);
80SCM_API SCM scm_with_continuation_barrier (SCM proc);
81
102dbb6f
LC
82SCM_INTERNAL SCM
83scm_i_with_continuation_barrier (scm_t_catch_body body,
84 void *body_data,
85 scm_t_catch_handler handler,
86 void *handler_data,
87 scm_t_catch_handler pre_unwind_handler,
88 void *pre_unwind_handler_data);
9de87eea 89
102dbb6f 90SCM_INTERNAL void scm_init_continuations (void);
0f2d19dd 91
b29058ff 92#endif /* SCM_CONTINUATIONS_H */
89e00824
ML
93
94/*
95 Local Variables:
96 c-file-style: "gnu"
97 End:
98*/