*** empty log message ***
[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
6/* Copyright (C) 1995,1996,2000,2001 Free Software Foundation, Inc.
7 *
73be1d9e
MV
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
b29058ff 12 *
73be1d9e 13 * This library is distributed in the hope that it will be useful,
0f2d19dd 14 * but 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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
b29058ff 22
0f2d19dd 23\f
b29058ff 24
b4309c3c 25#include "libguile/__scm.h"
0f2d19dd 26
766c5eaf 27#ifdef __ia64__
6a535440 28#include <signal.h>
766c5eaf 29#include <sys/ucontext.h>
87855fa2
MV
30extern unsigned long * __libc_ia64_register_backing_store_base;
31#endif /* __ia64__ */
0f2d19dd
JB
32\f
33
5f144b10 34/* a continuation SCM is a non-immediate pointing to a heap cell with:
2dbec7b5
GH
35 word 0: bits 0-15: smob type tag: scm_tc16_continuation.
36 bits 16-31: unused.
92c2555f 37 word 1: malloc block containing an scm_t_contregs structure with a
5f144b10
GH
38 tail array of SCM_STACKITEM. the size of the array is stored
39 in the num_stack_items field of the structure.
40*/
41
87855fa2 42SCM_API scm_t_bits scm_tc16_continuation;
5f144b10 43
0f2d19dd
JB
44typedef struct
45{
46 SCM throw_value;
47 jmp_buf jmpbuf;
48 SCM dynenv;
766c5eaf
RB
49#ifdef __ia64__
50 ucontext_t ctx;
51 void *backing_store;
52 unsigned long backing_store_size;
53#endif /* __ia64__ */
5f144b10 54 SCM_STACKITEM *base; /* base of the live stack, before it was saved. */
c014a02e
ML
55 size_t num_stack_items; /* size of the saved stack. */
56 unsigned long seq; /* dynamic root identifier. */
0f2d19dd 57
5f144b10
GH
58 /* the most recently created debug frame on the live stack, before
59 it was saved. */
92c2555f 60 struct scm_t_debug_frame *dframe;
d0f6ceb8 61
5f144b10 62 SCM_STACKITEM stack[1]; /* copied stack of size num_stack_items. */
92c2555f 63} scm_t_contregs;
1be6b49c 64
e841c3e0 65#define SCM_CONTINUATIONP(x) SCM_TYP16_PREDICATE (scm_tc16_continuation, x)
8b3bda20 66
92c2555f 67#define SCM_CONTREGS(x) ((scm_t_contregs *) SCM_CELL_WORD_1 (x))
8b3bda20 68
5f144b10 69#define SCM_CONTINUATION_LENGTH(x) (SCM_CONTREGS (x)->num_stack_items)
34d19ef6 70#define SCM_SET_CONTINUATION_LENGTH(x, n)\
5f144b10 71 (SCM_CONTREGS (x)->num_stack_items = (n))
8b3bda20
DH
72#define SCM_JMPBUF(x) ((SCM_CONTREGS (x))->jmpbuf)
73#define SCM_DYNENV(x) ((SCM_CONTREGS (x))->dynenv)
74#define SCM_THROW_VALUE(x) ((SCM_CONTREGS (x))->throw_value)
75#define SCM_BASE(x) ((SCM_CONTREGS (x))->base)
76#define SCM_SEQ(x) ((SCM_CONTREGS (x))->seq)
77#define SCM_DFRAME(x) ((SCM_CONTREGS (x))->dframe)
0f2d19dd
JB
78
79\f
80
87855fa2
MV
81SCM_API SCM scm_make_continuation (int *first);
82SCM_API void scm_init_continuations (void);
0f2d19dd 83
b29058ff 84#endif /* SCM_CONTINUATIONS_H */
89e00824
ML
85
86/*
87 Local Variables:
88 c-file-style: "gnu"
89 End:
90*/