* eval.c (RETURN): Wrap in do{}while(0) in order to make it
[bpt/guile.git] / libguile / continuations.h
... / ...
CommitLineData
1/* classes: h_files */
2
3#ifndef SCM_CONTINUATIONS_H
4#define SCM_CONTINUATIONS_H
5
6/* Copyright (C) 1995,1996,2000,2001 Free Software Foundation, Inc.
7 *
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.
12 *
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.
17 *
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
20 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307 USA
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.
45 * If you do not wish that, delete this exception notice. */
46
47\f
48
49#include "libguile/__scm.h"
50
51#ifdef __ia64__
52#include <sys/ucontext.h>
53extern unsigned long * __libc_ia64_register_backing_store_base;
54#endif /* __ia64__ */
55\f
56
57/* a continuation SCM is a non-immediate pointing to a heap cell with:
58 word 0: bits 0-15: smob type tag: scm_tc16_continuation.
59 bits 16-31: unused.
60 word 1: malloc block containing an scm_t_contregs structure with a
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
65SCM_API scm_t_bits scm_tc16_continuation;
66
67typedef struct
68{
69 SCM throw_value;
70 jmp_buf jmpbuf;
71 SCM dynenv;
72#ifdef __ia64__
73 ucontext_t ctx;
74 void *backing_store;
75 unsigned long backing_store_size;
76#endif /* __ia64__ */
77 SCM_STACKITEM *base; /* base of the live stack, before it was saved. */
78 size_t num_stack_items; /* size of the saved stack. */
79 unsigned long seq; /* dynamic root identifier. */
80
81#ifdef DEBUG_EXTENSIONS
82 /* the most recently created debug frame on the live stack, before
83 it was saved. */
84 struct scm_t_debug_frame *dframe;
85#endif
86 SCM_STACKITEM stack[1]; /* copied stack of size num_stack_items. */
87} scm_t_contregs;
88
89#define SCM_CONTINUATIONP(x) SCM_TYP16_PREDICATE (scm_tc16_continuation, x)
90
91#define SCM_CONTREGS(x) ((scm_t_contregs *) SCM_CELL_WORD_1 (x))
92
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))
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)
102
103\f
104
105SCM_API SCM scm_make_continuation (int *first);
106SCM_API void scm_init_continuations (void);
107
108#endif /* SCM_CONTINUATIONS_H */
109
110/*
111 Local Variables:
112 c-file-style: "gnu"
113 End:
114*/