.
[glibc/history.git] / setjmp / setjmp.h
blobf0babc047b560621c796f4144e54d8d452b8fe27
1 /* Copyright (C) 1991-1999, 2001, 2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
20 * ISO C99 Standard: 7.13 Nonlocal jumps <setjmp.h>
23 #ifndef _SETJMP_H
24 #define _SETJMP_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 #include <bits/setjmp.h> /* Get `__jmp_buf'. */
31 #include <bits/sigset.h> /* Get `__sigset_t'. */
33 __BEGIN_NAMESPACE_STD
35 /* Calling environment, plus possibly a saved signal mask. */
36 typedef struct __jmp_buf_tag /* C++ doesn't like tagless structs. */
38 /* NOTE: The machine-dependent definitions of `__sigsetjmp'
39 assume that a `jmp_buf' begins with a `__jmp_buf' and that
40 `__mask_was_saved' follows it. Do not move these members
41 or add others before it. */
42 __jmp_buf __jmpbuf; /* Calling environment. */
43 int __mask_was_saved; /* Saved the signal mask? */
44 __sigset_t __saved_mask; /* Saved signal mask. */
45 } jmp_buf[1];
48 /* Store the calling environment in ENV, also saving the signal mask.
49 Return 0. */
50 extern int setjmp (jmp_buf __env) __THROW;
52 __END_NAMESPACE_STD
53 __USING_NAMESPACE_STD(__jmp_buf_tag)
55 /* Store the calling environment in ENV, also saving the
56 signal mask if SAVEMASK is nonzero. Return 0.
57 This is the internal name for `sigsetjmp'. */
58 extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROW;
60 #ifndef __FAVOR_BSD
61 /* Store the calling environment in ENV, not saving the signal mask.
62 Return 0. */
63 extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROW;
65 /* Do not save the signal mask. This is equivalent to the `_setjmp'
66 BSD function. */
67 # define setjmp(env) _setjmp (env)
68 #else
69 /* We are in 4.3 BSD-compatibility mode in which `setjmp'
70 saves the signal mask like `sigsetjmp (ENV, 1)'. We have to
71 define a macro since ISO C says `setjmp' is one. */
72 # define setjmp(env) setjmp (env)
73 #endif /* Favor BSD. */
76 __BEGIN_NAMESPACE_STD
78 /* Jump to the environment saved in ENV, making the
79 `setjmp' call there return VAL, or 1 if VAL is 0. */
80 extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
81 __THROW __attribute__ ((__noreturn__));
83 __END_NAMESPACE_STD
85 #if defined __USE_BSD || defined __USE_XOPEN
86 /* Same. Usually `_longjmp' is used with `_setjmp', which does not save
87 the signal mask. But it is how ENV was saved that determines whether
88 `longjmp' restores the mask; `_longjmp' is just an alias. */
89 extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
90 __THROW __attribute__ ((__noreturn__));
91 #endif
94 #ifdef __USE_POSIX
95 /* Use the same type for `jmp_buf' and `sigjmp_buf'.
96 The `__mask_was_saved' flag determines whether
97 or not `longjmp' will restore the signal mask. */
98 typedef struct __jmp_buf_tag sigjmp_buf[1];
100 /* Store the calling environment in ENV, also saving the
101 signal mask if SAVEMASK is nonzero. Return 0. */
102 # define sigsetjmp(env, savemask) __sigsetjmp (env, savemask)
104 /* Jump to the environment saved in ENV, making the
105 sigsetjmp call there return VAL, or 1 if VAL is 0.
106 Restore the signal mask if that sigsetjmp call saved it.
107 This is just an alias `longjmp'. */
108 extern void siglongjmp (sigjmp_buf __env, int __val)
109 __THROW __attribute__ ((__noreturn__));
110 #endif /* Use POSIX. */
112 __END_DECLS
114 #endif /* setjmp.h */