HP C/iX Library Reference Manual (30026-90004)

Chapter 5 305
HP C/iX Library Function Descriptions
setjmp
setjmp
Saves the current environment.
Syntax
#include <setjmp.h>
int setjmp (jmp_buf
env
);
Parameters
env
An array of unsigned integers as defined by the type jmp_buf.
Return Values
0 Successful completion of setjmp().
0 Returned as a result of a call to longjmp(). The value returned is the
value passed in the
val
parameter of longjmp().
Description
The setjmp macro creates an entry point in your program that can be reached with
longjmp().
The setjmp macro saves the current environment of the calling process in the
env
parameter. The parameter
env
is of type jmp_buf, defined in <setjmp.h>. It is an array of
unsigned integers and therefore the
env
argument does not require an & operator.
A subsequent call to longjmp() requires that the
env
variable initialized by setjmp() be
passed as a parameter. This allows longjmp() to restore the program environment saved
by setjmp() and to continue program execution just after the setjmp() statement.
Upon successful completion, the setjmp() macro returns a zero value. A zero indicates
that the return is from setjmp() itself and not a return as a result of a call to longjmp().
If a nonzero value is returned, this indicates that the return is a result of a call to
longjmp(). After the call to longjmp() is completed, the program executes as if the call to
setjmp() (which stored information into the
env
argument) had returned a second time.
The result of the second return from setjmp() is the return of the value of the nonzero
val
argument supplied to longjmp().
See Also
longjmp(), ANSI C 4.6.1.1, POSIX.1 8.1