setjmp, longjmp - non-local goto


#include <setjmp_p.h>

int setjmp (env)
jmp_buf env;

longjmp (env, val)
jmp_buf env;


These routines are useful for dealing with errors and interrupts encountered in a low-level subroutine of a porgram.

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 returns in such a way that execution continues as if the call of setjmp had just returned the value val to the corresponding call to setjmp, which must not itself have returned in the interim. longjmp cannot return the value 0. If longjmp is invoked with it's second argument 0, it will return a 1. All accessible data have values as of the time longjmp was called.