| 1 | /* __libc_siglongjmp for x86. | 
|---|
| 2 | Copyright (C) 2018-2020 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 | <https://www.gnu.org/licenses/>.  */ | 
|---|
| 18 |  | 
|---|
| 19 | #define __libc_longjmp __redirect___libc_longjmp | 
|---|
| 20 | #include <setjmp/longjmp.c> | 
|---|
| 21 | #undef __libc_longjmp | 
|---|
| 22 |  | 
|---|
| 23 | extern void __longjmp_cancel (__jmp_buf __env, int __val) | 
|---|
| 24 | __attribute__ ((__noreturn__)) attribute_hidden; | 
|---|
| 25 |  | 
|---|
| 26 | /* Since __libc_longjmp is a private interface for cancellation | 
|---|
| 27 | implementation in libpthread, there is no need to restore shadow | 
|---|
| 28 | stack register.  */ | 
|---|
| 29 |  | 
|---|
| 30 | void | 
|---|
| 31 | __libc_longjmp (sigjmp_buf env, int val) | 
|---|
| 32 | { | 
|---|
| 33 | /* Perform any cleanups needed by the frames being unwound.  */ | 
|---|
| 34 | _longjmp_unwind (env, val); | 
|---|
| 35 |  | 
|---|
| 36 | if (env[0].__mask_was_saved) | 
|---|
| 37 | /* Restore the saved signal mask.  */ | 
|---|
| 38 | (void) __sigprocmask (SIG_SETMASK, | 
|---|
| 39 | (sigset_t *) &env[0].__saved_mask, | 
|---|
| 40 | (sigset_t *) NULL); | 
|---|
| 41 |  | 
|---|
| 42 | /* Call the machine-dependent function to restore machine state | 
|---|
| 43 | without shadow stack.  */ | 
|---|
| 44 | __longjmp_cancel (env[0].__jmpbuf, val ?: 1); | 
|---|
| 45 | } | 
|---|
| 46 |  | 
|---|