Sun Studio 12: Fortran Library Reference

1.4.34 longjmp, isetjmp: Return to Location Set by isetjmp

isetjmp sets a location for longjmp; longjmp returns to that location.

1.4.34.1 isetjmp: Set the Location for longjmp

This intrinsic function is called by:

ival = isetjmp( env )

env

INTEGER*4

Output 

env is a 12-element integer array.In 64-bit environments it must be declared INTEGER*8

Return value 

INTEGER*4

Output 

ival = 0 if isetjmp is called explicitly

ival ≠ 0 if isetjmp is called through longjmp

1.4.34.2 longjmp: Return to the Location Set by isetjmp

The subroutine is called by:

call longjmp( env, ival )

env

INTEGER*4

Input 

env is the 12-word integer array initialized by isetjmp.In 64-bit environments it must be declared INTEGER*8

ival

INTEGER*4

Output 

ival = 0 if isetjmp is called explicitly

ival ≠ 0 if isetjmp is called through longjmp

Description

The isetjmp and longjmp routines are used to deal with errors and interrupts encountered in a low-level routine of a program. They are f95 intrinsics.

These routines should be used only as a last resort. They require discipline, and are not portable. Read the man page, setjmp(3V), 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 )
       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 )
       return
       end

Restrictions

See setjmp(3V).