The source files `continue.h' and `continue.c' are designed to
function as an independent resource for programs wishing to use
continuations, but without all the rest of the SCM machinery. The
concept of continuations is explained in call-with-current-continuation.
The C constructs jmp_buf, setjmp, and longjmp
implement escape continuations. On VAX and Cray platforms, the setjmp
provided does not save all the registers. The source files
`setjump.mar', `setjump.s', and `ugsetjump.s' provide
implementations which do meet this criteria.
SCM uses the names jump_buf, setjump, and longjump
in lieu of jmp_buf, setjmp, and longjmp to prevent
name and declaration conflicts.
typedefed structure holding all the information needed to
represent a continuation. The other slot can be used to hold any
data the user wishes to put there by defining the macro
CONTINUATION_OTHER.
SHORT_ALIGN is #defined (in `scmfig.h'), then the
it is assumed that pointers in the stack can be aligned on short int boundaries.
SHORT_ALIGN
being #defined or not.
CHEAP_CONTINUATIONS is #defined (in `scmfig.h')
each CONTINUATION has size sizeof CONTINUATION.
Otherwise, all but root CONTINUATIONs have additional
storage (immediately following) to contain a copy of part of the stack.
Note: On systems with nonlinear stack disciplines (multiple
stacks or non-contiguous stack frames) copying the stack will not work
properly. These systems need to #define CHEAP_CONTINUATIONS in
`scmfig.h'.
#defined or not.
throw_to_continuation.
STACKITEM which fit between
start and the current top of stack. No check is done in this
routine to ensure that start is actually in the current stack
segment.
malloc) storage for a CONTINUATION of the
current extent of stack. This newly allocated CONTINUATION is
returned if successful, 0 if not. After
make_root_continuation returns, the calling routine still needs
to setjump(new_continuation->jmpbuf) in order to complete
the capture of this continuation.
CONTINUATION, copying (or
encapsulating) the stack state from parent_cont->stkbse to
the current top of stack. The newly allocated CONTINUATION is
returned if successful, 0q if not. After
make_continuation returns, the calling routine still needs to
setjump(new_continuation->jmpbuf) in order to complete the
capture of this continuation.
cont->other.
thrown_value to value and returns from the
continuation cont.
If CHEAP_CONTINUATIONS is #defined, then
throw_to_continuation does longjump(cont->jmpbuf, val).
If CHEAP_CONTINUATIONS is not #defined, the CONTINUATION
cont contains a copy of a portion of the C stack (whose bound must
be CONT(root_cont)->stkbse). Then:
longjump(cont->jmpbuf, val);