Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ setjmp(3) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sigaction, sigvec, signal



SETJMP(3,L)                 AIX Technical Reference                 SETJMP(3,L)



-------------------------------------------------------------------------------
setjmp, longjmp, _setjmp, _longjmp



PURPOSE

Saves and restores the current execution context.

LIBRARY

Standard C Library (libc.a)

SYNTAX

#include <setjmp.h>




                int setjmp (ctxt)           void longjmp (ctxt, val)
                jmp_buf ctxt;               jmp_buf ctxt;
                                            int val;
                int _setjmp (ctxt)
                jmp_buf ctxt;

                void _longjmp (ctxt, val)
                jmp_buf ctxt;
                int val;



DESCRIPTION

The setjmp and longjmp subroutines can be useful when handling errors and
interrupts encountered in low-level subroutines of a program.

The setjmp subroutine saves the current stack context and signal mask in the
buffer specified by the ctxt parameter.  The setjmp subroutine returns a value
of 0.

The longjmp subroutine restores the stack context and signal mask that were
saved by the setjmp subroutine in the corresponding ctxt buffer.  After the
longjmp subroutine has completed, the program execution continues as if the
corresponding call to setjmp had just returned the value of the val parameter.
The subroutine that called setjmp must not have returned before the completion
of the longjmp subroutine.  Setjmp and longjmp save and restore the signal mask
sigmask, while _setjmp and _longjmp manipulate only the stack context.

The longjmp subroutine cannot return 0 to the previous context.  The value 0 is
reserved to indicate the actual return from the setjmp subroutine when first
called by the program.  If the longjmp subroutine is passed a val parameter of



Processed November 7, 1990        SETJMP(3,L)                                 1





SETJMP(3,L)                 AIX Technical Reference                 SETJMP(3,L)



0, then execution continues as if the corresponding call to the setjmp
subroutine had returned a value of 1.  All global and static data have values
as of the time the longjmp subroutine is called.

Warning:  If the longjmp subroutine is called with a ctxt parameter that was
not previously set by setjmp, or if the subroutine that made the corresponding
call to setjmp has already returned, then the results of the longjmp subroutine
are undefined.

RELATED INFORMATION

In this book:  "sigaction, sigvec, signal."











































Processed November 7, 1990        SETJMP(3,L)                                 2



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026