Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ setjmp(3) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

signal

sigvec

     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;
     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 param-
     eter.  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 subrou-
     tine 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.

     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 0, then execution continues as if the corre-
     sponding  call to  the setjmp  subroutine had  returned a
     value of  1.  All accessible  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:  "signal" and "sigvec."

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