~peter-pearse/ubuntu/natty/guile-1.8/prop001

« back to all changes in this revision

Viewing changes to libguile/continuations.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2006-11-09 03:11:16 UTC
  • Revision ID: james.westby@ubuntu.com-20061109031116-hu0q1jxqg12y6yeg
Tags: upstream-1.8.1+1
ImportĀ upstreamĀ versionĀ 1.8.1+1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* classes: h_files */
 
2
 
 
3
#ifndef SCM_CONTINUATIONS_H
 
4
#define SCM_CONTINUATIONS_H
 
5
 
 
6
/* Copyright (C) 1995,1996,2000,2001, 2006 Free Software Foundation, Inc.
 
7
 *
 
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.
 
12
 *
 
13
 * This library 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 GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
21
 */
 
22
 
 
23
 
 
24
 
 
25
#include "libguile/__scm.h"
 
26
 
 
27
#ifdef __ia64__
 
28
#include <signal.h>
 
29
#include <ucontext.h>
 
30
extern unsigned long * __libc_ia64_register_backing_store_base;
 
31
#endif /* __ia64__ */
 
32
 
 
33
 
 
34
/* a continuation SCM is a non-immediate pointing to a heap cell with:
 
35
   word 0: bits 0-15: smob type tag: scm_tc16_continuation.
 
36
           bits 16-31: unused.
 
37
   word 1: malloc block containing an scm_t_contregs structure with a
 
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
 
 
42
SCM_API scm_t_bits scm_tc16_continuation;
 
43
 
 
44
typedef struct 
 
45
{
 
46
  SCM throw_value;
 
47
  jmp_buf jmpbuf;
 
48
  SCM dynenv;
 
49
#ifdef __ia64__
 
50
  ucontext_t ctx;
 
51
  void *backing_store;
 
52
  unsigned long backing_store_size;
 
53
#endif /* __ia64__ */
 
54
  size_t num_stack_items;   /* size of the saved stack.  */
 
55
  SCM root;                 /* continuation root identifier.  */
 
56
 
 
57
  /* The offset from the live stack location to this copy.  This is
 
58
     used to adjust pointers from within the copied stack to the stack
 
59
     itself.
 
60
 
 
61
     Thus, when you read a pointer from the copied stack that points
 
62
     into the live stack, you need to add OFFSET so that it points
 
63
     into the copy.
 
64
  */
 
65
  scm_t_ptrdiff offset;
 
66
 
 
67
  /* The most recently created debug frame on the live stack, before
 
68
     it was saved.  This needs to be adjusted with OFFSET, above.
 
69
  */
 
70
  struct scm_t_debug_frame *dframe;
 
71
 
 
72
  SCM_STACKITEM stack[1];    /* copied stack of size num_stack_items.  */ 
 
73
} scm_t_contregs;
 
74
 
 
75
#define SCM_CONTINUATIONP(x)    SCM_TYP16_PREDICATE (scm_tc16_continuation, x)
 
76
 
 
77
#define SCM_CONTREGS(x)         ((scm_t_contregs *) SCM_CELL_WORD_1 (x))
 
78
 
 
79
#define SCM_CONTINUATION_LENGTH(x) (SCM_CONTREGS (x)->num_stack_items)
 
80
#define SCM_SET_CONTINUATION_LENGTH(x, n)\
 
81
   (SCM_CONTREGS (x)->num_stack_items = (n))
 
82
#define SCM_JMPBUF(x)            ((SCM_CONTREGS (x))->jmpbuf)
 
83
#define SCM_DYNENV(x)            ((SCM_CONTREGS (x))->dynenv)
 
84
#define SCM_THROW_VALUE(x)       ((SCM_CONTREGS (x))->throw_value)
 
85
#define SCM_CONTINUATION_ROOT(x) ((SCM_CONTREGS (x))->root)   
 
86
#define SCM_DFRAME(x)            ((SCM_CONTREGS (x))->dframe)
 
87
 
 
88
 
 
89
 
 
90
SCM_API SCM scm_make_continuation (int *first);
 
91
 
 
92
SCM_API void *scm_c_with_continuation_barrier (void *(*func)(void*), void *);
 
93
SCM_API SCM scm_with_continuation_barrier (SCM proc);
 
94
 
 
95
SCM_API SCM scm_i_with_continuation_barrier (scm_t_catch_body body,
 
96
                                             void *body_data,
 
97
                                             scm_t_catch_handler handler,
 
98
                                             void *handler_data,
 
99
                                             scm_t_catch_handler pre_unwind_handler,
 
100
                                             void *pre_unwind_handler_data);
 
101
 
 
102
SCM_API void scm_init_continuations (void);
 
103
 
 
104
#endif  /* SCM_CONTINUATIONS_H */
 
105
 
 
106
/*
 
107
  Local Variables:
 
108
  c-file-style: "gnu"
 
109
  End:
 
110
*/