Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Coherent 3.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


longjmp()                General Function               longjmp()




Return from a non-local goto

#include <setjmp.h>
int longjmp(env, rval) jmp_buf env; int rval;

The function call is the only mechanism that C provides to trans-
fer control between  functions.  This mechanism is inadequate for
some purposes,  such as handling unexpected  errors or interrupts
at  lower levels  of  a program.   To answer  this need,  longjmp
provides a non-local goto.

longjmp restores an environment that had been saved by a previous
call to  the function setjmp.   It returns the value  rval to the
caller of  setjmp, just as if the setjmp  call had just returned.
Note that  longjmp must not restore the  environment of a routine
that has  already returned.  The type  declaration for jmp_buf is
in the header  file setjmp.h.  The environment saved includes the
program counter, stack  pointer, and stack frame.  These routines
do not restore register variables in the environment returned.

***** Example *****

For an example of this function, see the entry for longjmp.

***** See Also *****

general functions, setjmp()

***** Notes *****

Programmers should  note that many user-level  routines cannot be
interrupted and reentered  safely.  For that reason, improper use
of longjmp  and setjmp can  result in the  creation of mysterious
and irreproducible bugs.  Do not attempt to use longjmp within an
exception handler.





















COHERENT Lexicon                                           Page 1


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026