* benchmark-guile.in: Copied from check-guile.in and adapted for
[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 *
0f2d19dd
JB
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)
11 * any later version.
b29058ff 12 *
0f2d19dd
JB
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.
b29058ff 17 *
0f2d19dd
JB
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
82892bed
JB
20 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307 USA
0f2d19dd
JB
22 *
23 * As a special exception, the Free Software Foundation gives permission
24 * for additional uses of the text contained in its release of GUILE.
25 *
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.
31 *
32 * This exception does not however invalidate any other reasons why
33 * the executable file might be covered by the GNU General Public License.
34 *
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.
42 *
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.
82892bed 45 * If you do not wish that, delete this exception notice. */
b29058ff 46
0f2d19dd 47\f
b29058ff 48
b4309c3c 49#include "libguile/__scm.h"
0f2d19dd 50
766c5eaf
RB
51#ifdef __ia64__
52#include <sys/ucontext.h>
87855fa2
MV
53extern unsigned long * __libc_ia64_register_backing_store_base;
54#endif /* __ia64__ */
0f2d19dd
JB
55\f
56
5f144b10 57/* a continuation SCM is a non-immediate pointing to a heap cell with:
2dbec7b5
GH
58 word 0: bits 0-15: smob type tag: scm_tc16_continuation.
59 bits 16-31: unused.
92c2555f 60 word 1: malloc block containing an scm_t_contregs structure with a
5f144b10
GH
61 tail array of SCM_STACKITEM. the size of the array is stored
62 in the num_stack_items field of the structure.
63*/
64
87855fa2 65SCM_API scm_t_bits scm_tc16_continuation;
5f144b10 66
0f2d19dd
JB
67typedef struct
68{
69 SCM throw_value;
70 jmp_buf jmpbuf;
71 SCM dynenv;
766c5eaf
RB
72#ifdef __ia64__
73 ucontext_t ctx;
74 void *backing_store;
75 unsigned long backing_store_size;
76#endif /* __ia64__ */
5f144b10 77 SCM_STACKITEM *base; /* base of the live stack, before it was saved. */
c014a02e
ML
78 size_t num_stack_items; /* size of the saved stack. */
79 unsigned long seq; /* dynamic root identifier. */
0f2d19dd
JB
80
81#ifdef DEBUG_EXTENSIONS
5f144b10
GH
82 /* the most recently created debug frame on the live stack, before
83 it was saved. */
92c2555f 84 struct scm_t_debug_frame *dframe;
0f2d19dd 85#endif
5f144b10 86 SCM_STACKITEM stack[1]; /* copied stack of size num_stack_items. */
92c2555f 87} scm_t_contregs;
1be6b49c 88
e841c3e0 89#define SCM_CONTINUATIONP(x) SCM_TYP16_PREDICATE (scm_tc16_continuation, x)
8b3bda20 90
92c2555f 91#define SCM_CONTREGS(x) ((scm_t_contregs *) SCM_CELL_WORD_1 (x))
8b3bda20 92
5f144b10
GH
93#define SCM_CONTINUATION_LENGTH(x) (SCM_CONTREGS (x)->num_stack_items)
94#define SCM_SET_CONTINUATION_LENGTH(x,n)\
95 (SCM_CONTREGS (x)->num_stack_items = (n))
8b3bda20
DH
96#define SCM_JMPBUF(x) ((SCM_CONTREGS (x))->jmpbuf)
97#define SCM_DYNENV(x) ((SCM_CONTREGS (x))->dynenv)
98#define SCM_THROW_VALUE(x) ((SCM_CONTREGS (x))->throw_value)
99#define SCM_BASE(x) ((SCM_CONTREGS (x))->base)
100#define SCM_SEQ(x) ((SCM_CONTREGS (x))->seq)
101#define SCM_DFRAME(x) ((SCM_CONTREGS (x))->dframe)
0f2d19dd
JB
102
103\f
104
87855fa2
MV
105SCM_API SCM scm_make_continuation (int *first);
106SCM_API void scm_init_continuations (void);
0f2d19dd 107
b29058ff 108#endif /* SCM_CONTINUATIONS_H */
89e00824
ML
109
110/*
111 Local Variables:
112 c-file-style: "gnu"
113 End:
114*/