Back to index

glibc  2.9
setjmp.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991-1999, 2001, 2002, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /*
00020  *     ISO C99 Standard: 7.13 Nonlocal jumps     <setjmp.h>
00021  */
00022 
00023 #ifndef       _SETJMP_H
00024 #define       _SETJMP_H     1
00025 
00026 #include <features.h>
00027 
00028 __BEGIN_DECLS
00029 
00030 #include <bits/setjmp.h>           /* Get `__jmp_buf'.  */
00031 #include <bits/sigset.h>           /* Get `__sigset_t'.  */
00032 
00033 
00034 /* Calling environment, plus possibly a saved signal mask.  */
00035 struct __jmp_buf_tag
00036   {
00037     /* NOTE: The machine-dependent definitions of `__sigsetjmp'
00038        assume that a `jmp_buf' begins with a `__jmp_buf' and that
00039        `__mask_was_saved' follows it.  Do not move these members
00040        or add others before it.  */
00041     __jmp_buf __jmpbuf;            /* Calling environment.  */
00042     int __mask_was_saved;   /* Saved the signal mask?  */
00043     __sigset_t __saved_mask;       /* Saved signal mask.  */
00044   };
00045 
00046 
00047 __BEGIN_NAMESPACE_STD
00048 
00049 typedef struct __jmp_buf_tag jmp_buf[1];
00050 
00051 /* Store the calling environment in ENV, also saving the signal mask.
00052    Return 0.  */
00053 extern int setjmp (jmp_buf __env) __THROW;
00054 
00055 __END_NAMESPACE_STD
00056 
00057 /* Store the calling environment in ENV, also saving the
00058    signal mask if SAVEMASK is nonzero.  Return 0.
00059    This is the internal name for `sigsetjmp'.  */
00060 extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROW;
00061 
00062 #ifndef       __FAVOR_BSD
00063 /* Store the calling environment in ENV, not saving the signal mask.
00064    Return 0.  */
00065 extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROW;
00066 
00067 /* Do not save the signal mask.  This is equivalent to the `_setjmp'
00068    BSD function.  */
00069 # define setjmp(env) _setjmp (env)
00070 #else
00071 /* We are in 4.3 BSD-compatibility mode in which `setjmp'
00072    saves the signal mask like `sigsetjmp (ENV, 1)'.  We have to
00073    define a macro since ISO C says `setjmp' is one.  */
00074 # define setjmp(env) setjmp (env)
00075 #endif /* Favor BSD.  */
00076 
00077 
00078 __BEGIN_NAMESPACE_STD
00079 
00080 /* Jump to the environment saved in ENV, making the
00081    `setjmp' call there return VAL, or 1 if VAL is 0.  */
00082 extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
00083      __THROW __attribute__ ((__noreturn__));
00084 
00085 __END_NAMESPACE_STD
00086 
00087 #if defined __USE_BSD || defined __USE_XOPEN
00088 /* Same.  Usually `_longjmp' is used with `_setjmp', which does not save
00089    the signal mask.  But it is how ENV was saved that determines whether
00090    `longjmp' restores the mask; `_longjmp' is just an alias.  */
00091 extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
00092      __THROW __attribute__ ((__noreturn__));
00093 #endif
00094 
00095 
00096 #ifdef __USE_POSIX
00097 /* Use the same type for `jmp_buf' and `sigjmp_buf'.
00098    The `__mask_was_saved' flag determines whether
00099    or not `longjmp' will restore the signal mask.  */
00100 typedef struct __jmp_buf_tag sigjmp_buf[1];
00101 
00102 /* Store the calling environment in ENV, also saving the
00103    signal mask if SAVEMASK is nonzero.  Return 0.  */
00104 # define sigsetjmp(env, savemask)  __sigsetjmp (env, savemask)
00105 
00106 /* Jump to the environment saved in ENV, making the
00107    sigsetjmp call there return VAL, or 1 if VAL is 0.
00108    Restore the signal mask if that sigsetjmp call saved it.
00109    This is just an alias `longjmp'.  */
00110 extern void siglongjmp (sigjmp_buf __env, int __val)
00111      __THROW __attribute__ ((__noreturn__));
00112 #endif /* Use POSIX.  */
00113 
00114 __END_DECLS
00115 
00116 #endif /* setjmp.h  */