9srv Manual Collection/plan9/setjmp(2) | 9srv Manual Collection/plan9/setjmp(2) |
---|
int setjmp(jmp_buf env)
void longjmp(jmp_buf env, int val)
void notejmp(void *uregs, jmp_buf env, int val)
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(2)). The uregs argument should be the first argument passed to the note handler.
Setjmp and longjmp can also be used to switch stacks. Several macros are defined in /$objtype/include/u.h that can be used to build jmp_bufs by hand. The following code establishes a jmp_buf that may be called by longjmp to begin execution in a function f with 1024 bytes of stack:
9srv Manual Collection/plan9/setjmp(2) | Rev: Sun Dec 02 23:42:18 GMT 2007 |