blob: 99e3dc8cd019d36825ca4002fb31a5f3394ee97d [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* Copyright (C) 1991-1999, 2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
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. */
18
19/*
20 * ISO C99 Standard: 7.13 Nonlocal jumps <setjmp.h>
21 */
22
23#ifndef _SETJMP_H
24#define _SETJMP_H 1
25
26#include <features.h>
27
28__BEGIN_DECLS
29
30#include <bits/setjmp.h> /* Get `__jmp_buf'. */
31#include <bits/sigset.h> /* Get `__sigset_t'. */
32
33/* Calling environment, plus possibly a saved signal mask. */
34typedef struct __jmp_buf_tag /* C++ doesn't like tagless structs. */
35 {
36 /* NOTE: The machine-dependent definitions of `__sigsetjmp'
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. */
40 __jmp_buf __jmpbuf; /* Calling environment. */
41 int __mask_was_saved; /* Saved the signal mask? */
42 __sigset_t __saved_mask; /* Saved signal mask. */
43 } jmp_buf[1];
44
45
46/* Store the calling environment in ENV, also saving the signal mask.
47 Return 0. */
48extern int setjmp (jmp_buf __env) __THROW;
49
50/* Store the calling environment in ENV, not saving the signal mask.
51 Return 0. */
52extern int _setjmp (jmp_buf __env) __THROW;
53
54/* Store the calling environment in ENV, also saving the
55 signal mask if SAVEMASK is nonzero. Return 0.
56 This is the internal name for `sigsetjmp'. */
57extern int __sigsetjmp (jmp_buf __env, int __savemask) __THROW;
58
59#ifndef __FAVOR_BSD
60/* Do not save the signal mask. This is equivalent to the `_setjmp'
61 BSD function. */
62# define setjmp(env) _setjmp (env)
63#else
64/* We are in 4.3 BSD-compatibility mode in which `setjmp'
65 saves the signal mask like `sigsetjmp (ENV, 1)'. We have to
66 define a macro since ISO C says `setjmp' is one. */
67# define setjmp(env) setjmp (env)
68#endif /* Favor BSD. */
69
70
71/* Jump to the environment saved in ENV, making the
72 `setjmp' call there return VAL, or 1 if VAL is 0. */
73extern void longjmp (jmp_buf __env, int __val)
74 __THROW __attribute__ ((__noreturn__));
75#if defined __USE_BSD || defined __USE_XOPEN
76/* Same. Usually `_longjmp' is used with `_setjmp', which does not save
77 the signal mask. But it is how ENV was saved that determines whether
78 `longjmp' restores the mask; `_longjmp' is just an alias. */
79extern void _longjmp (jmp_buf __env, int __val)
80 __THROW __attribute__ ((__noreturn__));
81#endif
82
83
84#ifdef __USE_POSIX
85/* Use the same type for `jmp_buf' and `sigjmp_buf'.
86 The `__mask_was_saved' flag determines whether
87 or not `longjmp' will restore the signal mask. */
88typedef jmp_buf sigjmp_buf;
89
90/* Store the calling environment in ENV, also saving the
91 signal mask if SAVEMASK is nonzero. Return 0. */
92# define sigsetjmp(env, savemask) __sigsetjmp (env, savemask)
93
94/* Jump to the environment saved in ENV, making the
95 sigsetjmp call there return VAL, or 1 if VAL is 0.
96 Restore the signal mask if that sigsetjmp call saved it.
97 This is just an alias `longjmp'. */
98extern void siglongjmp (sigjmp_buf __env, int __val)
99 __THROW __attribute__ ((__noreturn__));
100#endif /* Use POSIX. */
101
102__END_DECLS
103
104#endif /* setjmp.h */