setjmp(3) - Plan 9 from User Space

| SETJMP(3) | SETJMP(3)
| NAME
| setjmp, longjmp, notejmp – non-local goto
SYNOPSIS
| `#include <u.h> #include <libc.h>
` `int setjmp(jmp_buf env)
` `void longjmp(jmp_buf env, int val)
` `void notejmp(void *uregs, jmp_buf env, int val)`
DESCRIPTION
| These routines are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program.
Setjmp saves its stack environment in env for later use by longjmp. It returns value 0.
Longjmp restores the environment saved by the last call of setjmp. It then causes execution to continue as if the call of setjmp had just returned with value val. The invoker of setjmp must not itself have returned in the interim. All accessible data have values as of the time longjmp was called.
Notejmp is the same as longjmp except that it is to be called from within a note handler (see notify(3)). The uregs argument should be the first argument passed to the note handler.
Setjmp and longjmp can also be used to switch stacks.
SOURCE
| `/usr/lib/plan9/src/lib9/jmp.c`
SEE ALSO
| notify(3)
BUGS
| Notejmp cannot recover from an address trap or bus error (page fault) on the 680x0 architectures.
To avoid name conflicts with the underlying system, setjmp, longjmp, notejmp, and jmp_buf are preprocessor macros defined as p9setjmp, p9longjmp, p9notejmp, and p9jmp_buf; see intro(3).
P9setjmp is implemented as a preprocessor macro that calls sigsetjmp (see Unix’s setjmp(3)).