]>
Commit | Line | Data |
---|---|---|
dc825f85 | 1 | /* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. |
28f540f4 RM |
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 Library General Public License as | |
6 | published by the Free Software Foundation; either version 2 of the | |
7 | 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 | Library General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Library General Public | |
15 | License along with the GNU C Library; see the file COPYING.LIB. If | |
b0d20a87 | 16 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, |
28f540f4 RM |
17 | Cambridge, MA 02139, USA. */ |
18 | ||
19 | /* | |
20 | * ANSI Standard: 4.6 NON-LOCAL JUMPS <setjmp.h> | |
21 | */ | |
22 | ||
23 | #ifndef _SETJMP_H | |
24 | ||
25 | #define _SETJMP_H 1 | |
26 | #include <features.h> | |
27 | ||
28 | __BEGIN_DECLS | |
29 | ||
30 | /* Get the machine-dependent definition of `__jmp_buf'. */ | |
31 | #include <jmp_buf.h> | |
32 | #include <sigset.h> /* Get `__sigset_t'. */ | |
33 | ||
34 | /* Calling environment, plus possibly a saved signal mask. */ | |
299a95b9 | 35 | typedef struct __jmp_buf_tag /* C++ doesn't like tagless structs. */ |
28f540f4 RM |
36 | { |
37 | /* NOTE: The machine-dependent definitions of `__sigsetjmp' | |
38 | assume that a `jmp_buf' begins with a `__jmp_buf'. | |
39 | Do not move this member 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 | |
47 | signal mask if SAVEMASK is nonzero. Return 0. | |
48 | This is the internal name for `sigsetjmp'. */ | |
49 | extern int __sigsetjmp __P ((jmp_buf __env, int __savemask)); | |
50 | ||
51 | #ifndef __FAVOR_BSD | |
52 | /* Set ENV to the current position and return 0, not saving the signal mask. | |
53 | This is just like `sigsetjmp (ENV, 0)'. | |
54 | The ANSI C standard says `setjmp' is a macro. */ | |
55 | #define setjmp(env) __sigsetjmp ((env), 0) | |
56 | #else | |
dc825f85 | 57 | /* We are in 4.3 BSD-compatibility mode in which `setjmp' |
28f540f4 RM |
58 | saves the signal mask like `sigsetjmp (ENV, 1)'. */ |
59 | #define setjmp(env) __sigsetjmp ((env), 1) | |
60 | #endif /* Favor BSD. */ | |
61 | ||
62 | #ifdef __USE_BSD | |
63 | /* Set ENV to the current position and return 0, not saving the signal mask. | |
64 | This is the 4.3 BSD name for ANSI `setjmp'. */ | |
65 | #define _setjmp(env) __sigsetjmp ((env), 0) | |
66 | #endif | |
67 | ||
68 | ||
69 | /* Jump to the environment saved in ENV, making the | |
70 | `setjmp' call there return VAL, or 1 if VAL is 0. */ | |
71 | extern void longjmp __P ((jmp_buf __env, int __val)) | |
72 | __attribute__ ((__noreturn__)); | |
73 | #ifdef __USE_BSD | |
74 | /* Same. Usually `_longjmp' is used with `_setjmp', which does not save | |
75 | the signal mask. But it is how ENV was saved that determines whether | |
76 | `longjmp' restores the mask; `_longjmp' is just an alias. */ | |
77 | extern void _longjmp __P ((jmp_buf __env, int __val)) | |
78 | __attribute__ ((__noreturn__)); | |
79 | #endif /* Use BSD. */ | |
80 | ||
81 | /* Internal machine-dependent function to restore context sans signal mask. */ | |
82 | extern void __longjmp __P ((__jmp_buf __env, int __val)) | |
83 | __attribute__ ((__noreturn__)); | |
84 | ||
85 | /* Internal function to possibly save the current mask of blocked signals | |
86 | in ENV, and always set the flag saying whether or not it was saved. | |
87 | This is used by the machine-dependent definition of `__sigsetjmp'. | |
88 | Always returns zero, for convenience. */ | |
89 | extern int __sigjmp_save __P ((jmp_buf __env, int __savemask)); | |
90 | ||
91 | ||
92 | #ifdef __USE_POSIX | |
93 | /* Use the same type for `jmp_buf' and `sigjmp_buf'. | |
94 | The `__mask_was_saved' flag determines whether | |
95 | or not `longjmp' will restore the signal mask. */ | |
96 | typedef jmp_buf sigjmp_buf; | |
97 | ||
98 | /* Store the calling environment in ENV, also saving the | |
99 | signal mask if SAVEMASK is nonzero. Return 0. */ | |
100 | #define sigsetjmp(env, savemask) __sigsetjmp ((env), (savemask)) | |
101 | ||
102 | /* Jump to the environment saved in ENV, making the | |
103 | sigsetjmp call there return VAL, or 1 if VAL is 0. | |
104 | Restore the signal mask if that sigsetjmp call saved it. | |
105 | This is just an alias `longjmp'. */ | |
106 | extern void siglongjmp __P ((sigjmp_buf __env, int __val)) | |
107 | __attribute__ ((__noreturn__)); | |
108 | #endif /* Use POSIX. */ | |
109 | ||
110 | __END_DECLS | |
111 | ||
112 | #endif /* setjmp.h */ |