powerpc: Fix __fesetround_inline_nocheck on POWER9+ (BZ 31682)
[glibc.git] / sysdeps / s390 / s390-64 / __longjmp.c
blob133ad7a65774819b25604b51835761a4fdda81b2
1 /* Copyright (C) 2001-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
18 #include <errno.h>
19 #include <sysdep.h>
20 #include <pointer_guard.h>
21 #include <setjmp.h>
22 #include <bits/setjmp.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <stap-probe.h>
27 /* See sysdeps/unix/sysv/linux/s390/s390-64/pointer_guard.h. */
28 #if IS_IN (rtld)
29 # undef PTR_DEMANGLE
30 #endif
32 /* Jump to the position specified by ENV, causing the
33 setjmp call there to return VAL, or 1 if VAL is 0. */
34 void
35 __longjmp (__jmp_buf env, int val)
37 #ifdef PTR_DEMANGLE
38 uintptr_t guard = THREAD_GET_POINTER_GUARD ();
39 # ifdef CHECK_SP
40 CHECK_SP (env, guard);
41 # endif
42 #elif defined CHECK_SP
43 CHECK_SP (env, 0);
44 #endif
45 register long int r2 __asm__ ("%r2") = val == 0 ? 1 : val;
46 #ifdef PTR_DEMANGLE
47 register uintptr_t r3 __asm__ ("%r3") = guard;
48 register void *r1 __asm__ ("%r1") = (void *) env;
49 #endif
50 /* Restore registers and jump back. */
51 __asm__ __volatile__ (
52 /* longjmp probe expects longjmp first argument, second
53 argument and target address. */
54 #ifdef PTR_DEMANGLE
55 "lmg %%r4,%%r5,64(%1)\n\t"
56 "xgr %%r4,%2\n\t"
57 "xgr %%r5,%2\n\t"
58 LIBC_PROBE_ASM (longjmp, 8@%1 -4@%0 8@%%r4)
59 #else
60 LIBC_PROBE_ASM (longjmp, 8@%1 -4@%0 8@%%r14)
61 #endif
63 /* restore fpregs */
64 "ld %%f8,80(%1)\n\t"
65 "ld %%f9,88(%1)\n\t"
66 "ld %%f10,96(%1)\n\t"
67 "ld %%f11,104(%1)\n\t"
68 "ld %%f12,112(%1)\n\t"
69 "ld %%f13,120(%1)\n\t"
70 "ld %%f14,128(%1)\n\t"
71 "ld %%f15,136(%1)\n\t"
73 /* restore gregs and return to jmp_buf target */
74 #ifdef PTR_DEMANGLE
75 "lmg %%r6,%%r13,0(%1)\n\t"
76 "lgr %%r15,%%r5\n\t"
77 LIBC_PROBE_ASM (longjmp_target, 8@%1 -4@%0 8@%%r4)
78 "br %%r4"
79 #else
80 "lmg %%r6,%%r15,0(%1)\n\t"
81 LIBC_PROBE_ASM (longjmp_target, 8@%1 -4@%0 8@%%r14)
82 "br %%r14"
83 #endif
84 : : "r" (r2),
85 #ifdef PTR_DEMANGLE
86 "r" (r1), "r" (r3)
87 #else
88 "a" (env)
89 #endif
92 /* Avoid `volatile function does return' warnings. */
93 for (;;);