]> git.ipfire.org Git - thirdparty/glibc.git/blame - setjmp/setjmp.h
Merge glibc-ports into ports/ directory.
[thirdparty/glibc.git] / setjmp / setjmp.h
CommitLineData
edc5984d 1/* Copyright (C) 1991-1999,2001,2002,2007,2009,2011 Free Software Foundation, Inc.
ba1ffaa1 2 This file is part of the GNU C Library.
28f540f4 3
ba1ffaa1 4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
28f540f4 8
ba1ffaa1
UD
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
41bdb6e2 12 Lesser General Public License for more details.
28f540f4 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
28f540f4
RM
17
18/*
d1646309 19 * ISO C99 Standard: 7.13 Nonlocal jumps <setjmp.h>
28f540f4
RM
20 */
21
22#ifndef _SETJMP_H
28f540f4 23#define _SETJMP_H 1
5107cf1d 24
28f540f4
RM
25#include <features.h>
26
27__BEGIN_DECLS
28
5107cf1d
UD
29#include <bits/setjmp.h> /* Get `__jmp_buf'. */
30#include <bits/sigset.h> /* Get `__sigset_t'. */
28f540f4 31
7a5affeb 32
28f540f4 33/* Calling environment, plus possibly a saved signal mask. */
2e0e802a 34struct __jmp_buf_tag
28f540f4
RM
35 {
36 /* NOTE: The machine-dependent definitions of `__sigsetjmp'
eca90c85
UD
37 assume that a `jmp_buf' begins with a `__jmp_buf' and that
38 `__mask_was_saved' follows it. Do not move these members
39 or add others before it. */
28f540f4
RM
40 __jmp_buf __jmpbuf; /* Calling environment. */
41 int __mask_was_saved; /* Saved the signal mask? */
42 __sigset_t __saved_mask; /* Saved signal mask. */
2e0e802a
UD
43 };
44
45
46__BEGIN_NAMESPACE_STD
28f540f4 47
2e0e802a 48typedef struct __jmp_buf_tag jmp_buf[1];
28f540f4 49
eca90c85
UD
50/* Store the calling environment in ENV, also saving the signal mask.
51 Return 0. */
edc5984d 52extern int setjmp (jmp_buf __env) __THROWNL;
eca90c85 53
7a5affeb 54__END_NAMESPACE_STD
eca90c85 55
28f540f4
RM
56/* Store the calling environment in ENV, also saving the
57 signal mask if SAVEMASK is nonzero. Return 0.
58 This is the internal name for `sigsetjmp'. */
edc5984d 59extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;
28f540f4
RM
60
61#ifndef __FAVOR_BSD
7a5affeb
UD
62/* Store the calling environment in ENV, not saving the signal mask.
63 Return 0. */
edc5984d 64extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;
7a5affeb 65
eca90c85
UD
66/* Do not save the signal mask. This is equivalent to the `_setjmp'
67 BSD function. */
68# define setjmp(env) _setjmp (env)
28f540f4 69#else
dc825f85 70/* We are in 4.3 BSD-compatibility mode in which `setjmp'
eca90c85
UD
71 saves the signal mask like `sigsetjmp (ENV, 1)'. We have to
72 define a macro since ISO C says `setjmp' is one. */
73# define setjmp(env) setjmp (env)
28f540f4
RM
74#endif /* Favor BSD. */
75
28f540f4 76
7a5affeb
UD
77__BEGIN_NAMESPACE_STD
78
28f540f4
RM
79/* Jump to the environment saved in ENV, making the
80 `setjmp' call there return VAL, or 1 if VAL is 0. */
7a5affeb 81extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
edc5984d 82 __THROWNL __attribute__ ((__noreturn__));
7a5affeb
UD
83
84__END_NAMESPACE_STD
85
f21acc89 86#if defined __USE_BSD || defined __USE_XOPEN
28f540f4
RM
87/* Same. Usually `_longjmp' is used with `_setjmp', which does not save
88 the signal mask. But it is how ENV was saved that determines whether
89 `longjmp' restores the mask; `_longjmp' is just an alias. */
7a5affeb 90extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
edc5984d 91 __THROWNL __attribute__ ((__noreturn__));
f21acc89 92#endif
28f540f4 93
28f540f4
RM
94
95#ifdef __USE_POSIX
96/* Use the same type for `jmp_buf' and `sigjmp_buf'.
97 The `__mask_was_saved' flag determines whether
98 or not `longjmp' will restore the signal mask. */
7a5affeb 99typedef struct __jmp_buf_tag sigjmp_buf[1];
28f540f4
RM
100
101/* Store the calling environment in ENV, also saving the
102 signal mask if SAVEMASK is nonzero. Return 0. */
eca90c85 103# define sigsetjmp(env, savemask) __sigsetjmp (env, savemask)
28f540f4
RM
104
105/* Jump to the environment saved in ENV, making the
106 sigsetjmp call there return VAL, or 1 if VAL is 0.
107 Restore the signal mask if that sigsetjmp call saved it.
108 This is just an alias `longjmp'. */
c1422e5b 109extern void siglongjmp (sigjmp_buf __env, int __val)
edc5984d 110 __THROWNL __attribute__ ((__noreturn__));
28f540f4
RM
111#endif /* Use POSIX. */
112
b50f8e42
UD
113
114/* Define helper functions to catch unsafe code. */
115#if __USE_FORTIFY_LEVEL > 0
116# include <bits/setjmp2.h>
117#endif
118
28f540f4
RM
119__END_DECLS
120
121#endif /* setjmp.h */