LONGJMP(3F)LONGJMP(3F)NAME
longjmp, isetjmp - longjmp returns to the location set by isetjmp
SYNOPSIS
Usage: isetjmp:
integer*4 env(12)
common /jmpblk/ env
j = isetjmp( env )
Usage: longjmp:
integer*4 env(12)
common /jmpblk/ env
call longjmp(env,ival)
When compiling for 64-bit environments, the 12-element array env used
by these routines must be declared INTEGER*8.
DESCRIPTION
The isetjmp and longjmp routines are used to deal with errors and
interrupts encountered in a low-level routine of a program. These rou‐
tines should be used only as a last resort, as they require discipline
and are not portable. Read the man page setjmp(3c) for bugs and other
details.
isetjmp saves the stack environment in env. It also saves the register
environment.
longjmp restores the environment saved by the last call to isetjmp, and
returns in such a way that execution continues as if the call to
isetjmp had just returned the value ival.
The integer expression ival returned from isetjmp is zero if longjmp is
not called, and nonzero if longjmp is called.
Example: Code fragment using isetjmp and longjmp:
integer*4 env(12)
common /jmpblk/ env
j = isetjmp( env ) ! <-- isetjmp
if ( j .eq. 0 ) then
call sbrtnA
else
call error_processor
end if
end
subroutine sbrtnA
integer*4 env(12)
common /jmpblk/ env
call longjmp( env, ival ) ! <-- longjmp
return
end
NOTE
You must invoke isetjmp before calling longjmp().
The argument to isetjmp must be a 12-integer array.
You must pass the env variable from the routine that calls isetjmp to
the routine that calls longjmp, either by common or as an argument.
longjmp() attempts to clean up the stack.
longjmp() must be called from a lower call-level than isetjmp().
Passing isetjmp as an argument that is a procedure name does not work.
BUGS
See setjmp(3c).
FILES
libC.a
SEE ALSOsetjmp(3C).
2002/11/27 LONGJMP(3F)