| 1 | /* Copyright (C) 1991-2020 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, see  |
| 16 | <https://www.gnu.org/licenses/>. */  |
| 17 |   |
| 18 | /*  |
| 19 | * ISO C99 Standard: 7.13 Nonlocal jumps <setjmp.h>  |
| 20 | */  |
| 21 |   |
| 22 | #ifndef _SETJMP_H  |
| 23 | #define _SETJMP_H 1  |
| 24 |   |
| 25 | #include <features.h>  |
| 26 |   |
| 27 | __BEGIN_DECLS  |
| 28 |   |
| 29 | #include <bits/setjmp.h> /* Get `__jmp_buf'. */  |
| 30 | #include <bits/types/__sigset_t.h>  |
| 31 |   |
| 32 | /* Calling environment, plus possibly a saved signal mask. */  |
| 33 | struct __jmp_buf_tag  |
| 34 | {  |
| 35 | /* NOTE: The machine-dependent definitions of `__sigsetjmp'  |
| 36 | assume that a `jmp_buf' begins with a `__jmp_buf' and that  |
| 37 | `__mask_was_saved' follows it. Do not move these members  |
| 38 | or add others before it. */  |
| 39 | __jmp_buf __jmpbuf; /* Calling environment. */  |
| 40 | int __mask_was_saved; /* Saved the signal mask? */  |
| 41 | __sigset_t __saved_mask; /* Saved signal mask. */  |
| 42 | };  |
| 43 |   |
| 44 |   |
| 45 | typedef struct __jmp_buf_tag jmp_buf[1];  |
| 46 |   |
| 47 | /* Store the calling environment in ENV, also saving the signal mask.  |
| 48 | Return 0. */  |
| 49 | extern int setjmp (jmp_buf __env) __THROWNL;  |
| 50 |   |
| 51 | /* Store the calling environment in ENV, also saving the  |
| 52 | signal mask if SAVEMASK is nonzero. Return 0.  |
| 53 | This is the internal name for `sigsetjmp'. */  |
| 54 | extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;  |
| 55 |   |
| 56 | /* Store the calling environment in ENV, not saving the signal mask.  |
| 57 | Return 0. */  |
| 58 | extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;  |
| 59 |   |
| 60 | /* Do not save the signal mask. This is equivalent to the `_setjmp'  |
| 61 | BSD function. */  |
| 62 | #define setjmp(env) _setjmp (env)  |
| 63 |   |
| 64 |   |
| 65 | /* Jump to the environment saved in ENV, making the  |
| 66 | `setjmp' call there return VAL, or 1 if VAL is 0. */  |
| 67 | extern void longjmp (struct __jmp_buf_tag __env[1], int __val)  |
| 68 | __THROWNL __attribute__ ((__noreturn__));  |
| 69 |   |
| 70 | #if defined __USE_MISC || defined __USE_XOPEN  |
| 71 | /* Same. Usually `_longjmp' is used with `_setjmp', which does not save  |
| 72 | the signal mask. But it is how ENV was saved that determines whether  |
| 73 | `longjmp' restores the mask; `_longjmp' is just an alias. */  |
| 74 | extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)  |
| 75 | __THROWNL __attribute__ ((__noreturn__));  |
| 76 | #endif  |
| 77 |   |
| 78 |   |
| 79 | #ifdef __USE_POSIX  |
| 80 | /* Use the same type for `jmp_buf' and `sigjmp_buf'.  |
| 81 | The `__mask_was_saved' flag determines whether  |
| 82 | or not `longjmp' will restore the signal mask. */  |
| 83 | typedef struct __jmp_buf_tag sigjmp_buf[1];  |
| 84 |   |
| 85 | /* Store the calling environment in ENV, also saving the  |
| 86 | signal mask if SAVEMASK is nonzero. Return 0. */  |
| 87 | # define sigsetjmp(env, savemask) __sigsetjmp (env, savemask)  |
| 88 |   |
| 89 | /* Jump to the environment saved in ENV, making the  |
| 90 | sigsetjmp call there return VAL, or 1 if VAL is 0.  |
| 91 | Restore the signal mask if that sigsetjmp call saved it.  |
| 92 | This is just an alias `longjmp'. */  |
| 93 | extern void siglongjmp (sigjmp_buf __env, int __val)  |
| 94 | __THROWNL __attribute__ ((__noreturn__));  |
| 95 | #endif /* Use POSIX. */  |
| 96 |   |
| 97 |   |
| 98 | /* Define helper functions to catch unsafe code. */  |
| 99 | #if __USE_FORTIFY_LEVEL > 0  |
| 100 | # include <bits/setjmp2.h>  |
| 101 | #endif  |
| 102 |   |
| 103 | __END_DECLS  |
| 104 |   |
| 105 | #endif /* setjmp.h */  |
| 106 | |