2.11BSD/man/cat3/_setjmp.0

Compare this file to the similar file:
Show the results in this format:




SETJMP(3)	    UNIX Programmer's Manual		SETJMP(3)



NAME
     setjmp, longjmp - non-local goto

SYNOPSIS
     #include <setjmp.h>

     setjmp(env)
     jmp_buf env;

     longjmp(env, val)
     jmp_buf env;

     _setjmp(env)
     jmp_buf env;

     _longjmp(env, val)
     jmp_buf env;

DESCRIPTION
     These routines are useful for dealing with errors and inter-
     rupts encountered in a low-level subroutine of a program.

     _S_e_t_j_m_p saves its stack environment in _e_n_v for later use by
     _l_o_n_g_j_m_p. It returns value 0.

     _L_o_n_g_j_m_p restores the environment saved by the last call of
     _s_e_t_j_m_p.  It then returns in such a way that execution con-
     tinues as if the call of _s_e_t_j_m_p had just returned the value
     _v_a_l to the function that invoked _s_e_t_j_m_p, which must not
     itself have returned in the interim.  All accessible data
     have values as of the time _l_o_n_g_j_m_p was called.

     _S_e_t_j_m_p and _l_o_n_g_j_m_p save and restore the signal mask _s_i_g_-
     _m_a_s_k(2), while __s_e_t_j_m_p and __l_o_n_g_j_m_p manipulate only the C
     stack and registers.

ERRORS
     If the contents of the jmp_buf are corrupted, or correspond
     to an environment that has already returned, _l_o_n_g_j_m_p calls
     the routine _l_o_n_g_j_m_p_e_r_r_o_r.	If _l_o_n_g_j_m_p_e_r_r_o_r returns the pro-
     gram is aborted.  The default version of _l_o_n_g_j_m_p_e_r_r_o_r prints
     the message ``longjmp botch'' to standard error and returns.
     User programs wishing to exit more gracefully can write
     their own versions of _l_o_n_g_j_m_p_e_r_r_o_r.

SEE ALSO
     sigvec(2), sigstack(2), signal(3)

NOTES  (PDP-11)
     On the PDP-11, _l_o_n_g_j_m_p_e_r_r_o_r is called as __l_j_e_r_r.  This
     difference stems from the limited name size of the PDP-11
     that requires all external names to be unique within the



Printed 11/26/99	 January 9, 1986			1






SETJMP(3)	    UNIX Programmer's Manual		SETJMP(3)



     first seven characters.  However, <_s_e_t_j_m_p._h> automatically
     translates _l_o_n_g_j_m_p_e_r_r_o_r to _l_j_e_r_r_o_r and should be included
     before any definition _l_o_n_g_j_m_p_e_r_r_o_r.

     The PDP-11 implementation also contains a subtle bug that
     occurs when a routine containing a _s_e_t_j_m_p has _r_e_g_i_s_t_e_r vari-
     ables.  The bug sometimes causes those variables to be given
     invalid values when a longjmp is made back to the routine.
     _R_e_g_i_s_t_e_r variables should therefore be avoided in routines
     containing _s_e_t_j_m_p_s.

     And finally, _longjmp may sometimes die fatally.  Sorry.











































Printed 11/26/99	 January 9, 1986			2