| 1 | /* Internal header file for <setjmp.h>. Linux/x86 version. |
| 2 | Copyright (C) 2017-2018 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library; if not, see |
| 17 | <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #ifndef _SETJMPP_H |
| 20 | #define _SETJMPP_H 1 |
| 21 | |
| 22 | #include <bits/types/__sigset_t.h> |
| 23 | |
| 24 | /* The biggest signal number + 1. As of kernel 4.14, x86 _NSIG is 64. |
| 25 | Define it to 513 to leave some rooms for future use. */ |
| 26 | #define _JUMP_BUF_SIGSET_NSIG 513 |
| 27 | /* Number of longs to hold all signals. */ |
| 28 | #define _JUMP_BUF_SIGSET_NWORDS \ |
| 29 | ((_JUMP_BUF_SIGSET_NSIG - 1 + 7) / (8 * sizeof (unsigned long int))) |
| 30 | |
| 31 | typedef struct |
| 32 | { |
| 33 | unsigned long int __val[_JUMP_BUF_SIGSET_NWORDS]; |
| 34 | } __jmp_buf_sigset_t; |
| 35 | |
| 36 | typedef union |
| 37 | { |
| 38 | __sigset_t __saved_mask_compat; |
| 39 | struct |
| 40 | { |
| 41 | __jmp_buf_sigset_t __saved_mask; |
| 42 | /* Used for shadow stack pointer. */ |
| 43 | unsigned long int __shadow_stack_pointer; |
| 44 | } __saved; |
| 45 | } __jmpbuf_arch_t; |
| 46 | |
| 47 | #undef __sigset_t |
| 48 | #define __sigset_t __jmpbuf_arch_t |
| 49 | #include <setjmp.h> |
| 50 | #undef __saved_mask |
| 51 | #define __saved_mask __saved_mask.__saved.__saved_mask |
| 52 | |
| 53 | #include <signal.h> |
| 54 | |
| 55 | #define _SIGPROCMASK_NSIG_WORDS (_NSIG / (8 * sizeof (unsigned long int))) |
| 56 | |
| 57 | typedef struct |
| 58 | { |
| 59 | unsigned long int __val[_SIGPROCMASK_NSIG_WORDS]; |
| 60 | } __sigprocmask_sigset_t; |
| 61 | |
| 62 | extern jmp_buf ___buf; |
| 63 | extern __typeof (___buf[0].__saved_mask) ___saved_mask; |
| 64 | _Static_assert (sizeof (___saved_mask) >= sizeof (__sigprocmask_sigset_t), |
| 65 | "size of ___saved_mask < size of __sigprocmask_sigset_t" ); |
| 66 | |
| 67 | #endif /* setjmpP.h */ |
| 68 | |