1 /* Copyright (C) 1991-2022 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 /* Copy of sysdeps/generic/longjmp.c modified for backward compatibility
19    with old non AltiVec/VMX longjmp.  */
20 
21 #include <bits/wordsize.h>
22 #include <shlib-compat.h>
23 #if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
24 # include <stddef.h>
25 # include <novmxsetjmp.h>
26 # include <signal.h>
27 
28 
29 /* Set the signal mask to the one specified in ENV, and jump
30    to the position specified in ENV, causing the setjmp
31    call there to return VAL, or 1 if VAL is 0.  */
32 void
__novmx__libc_siglongjmp(__novmx__sigjmp_buf env,int val)33 __novmx__libc_siglongjmp (__novmx__sigjmp_buf env, int val)
34 {
35   /* Perform any cleanups needed by the frames being unwound.  */
36   _longjmp_unwind (env, val);
37 
38   if (env[0].__mask_was_saved)
39     /* Restore the saved signal mask.  */
40     (void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
41 			  (sigset_t *) NULL);
42 
43   /* Call the machine-dependent function to restore machine state.  */
44   __novmx__longjmp (env[0].__jmpbuf, val ?: 1);
45 }
46 
47 strong_alias (__novmx__libc_siglongjmp, __novmx__libc_longjmp)
48 libc_hidden_def (__novmx__libc_longjmp)
49 weak_alias (__novmx__libc_siglongjmp, __novmx_longjmp)
50 weak_alias (__novmx__libc_siglongjmp, __novmxlongjmp)
51 weak_alias (__novmx__libc_siglongjmp, __novmxsiglongjmp)
52 
53 compat_symbol (libc, __novmx_longjmp, _longjmp, GLIBC_2_0);
54 compat_symbol (libc, __novmxlongjmp, longjmp, GLIBC_2_0);
55 compat_symbol (libc, __novmxsiglongjmp, siglongjmp, GLIBC_2_0);
56 #endif /* defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4))  */
57