]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/s390/s390-64/__longjmp.c
Remove "Contributed by" lines
[thirdparty/glibc.git] / sysdeps / s390 / s390-64 / __longjmp.c
CommitLineData
2b778ceb 1/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
847b055c 2 This file is part of the GNU C Library.
847b055c
AJ
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
847b055c
AJ
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
ffeac417 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
847b055c 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
847b055c
AJ
17
18#include <errno.h>
19#include <sysdep.h>
20#include <setjmp.h>
21#include <bits/setjmp.h>
22#include <stdlib.h>
23#include <unistd.h>
53244a4e 24#include <stap-probe.h>
847b055c
AJ
25
26/* Jump to the position specified by ENV, causing the
27 setjmp call there to return VAL, or 1 if VAL is 0. */
2f438e20 28void
847b055c
AJ
29__longjmp (__jmp_buf env, int val)
30{
00c2b3b9 31#ifdef PTR_DEMANGLE
7291c56f 32 uintptr_t guard = THREAD_GET_POINTER_GUARD ();
b8bb339f 33# ifdef CHECK_SP
7291c56f 34 CHECK_SP (env, guard);
b8bb339f
UD
35# endif
36#elif defined CHECK_SP
37 CHECK_SP (env, 0);
7291c56f 38#endif
31cf3942 39 register long int r2 __asm__ ("%r2") = val == 0 ? 1 : val;
7291c56f 40#ifdef PTR_DEMANGLE
31cf3942
SL
41 register uintptr_t r3 __asm__ ("%r3") = guard;
42 register void *r1 __asm__ ("%r1") = (void *) env;
00c2b3b9
UD
43#endif
44 /* Restore registers and jump back. */
31cf3942
SL
45 __asm__ __volatile__ (
46 /* longjmp probe expects longjmp first argument, second
47 argument and target address. */
53244a4e 48#ifdef PTR_DEMANGLE
31cf3942
SL
49 "lmg %%r4,%%r5,64(%1)\n\t"
50 "xgr %%r4,%2\n\t"
51 "xgr %%r5,%2\n\t"
52 LIBC_PROBE_ASM (longjmp, 8@%1 -4@%0 8@%%r4)
53244a4e 53#else
31cf3942 54 LIBC_PROBE_ASM (longjmp, 8@%1 -4@%0 8@%%r14)
53244a4e
SL
55#endif
56
31cf3942
SL
57 /* restore fpregs */
58 "ld %%f8,80(%1)\n\t"
59 "ld %%f9,88(%1)\n\t"
60 "ld %%f10,96(%1)\n\t"
61 "ld %%f11,104(%1)\n\t"
62 "ld %%f12,112(%1)\n\t"
63 "ld %%f13,120(%1)\n\t"
64 "ld %%f14,128(%1)\n\t"
65 "ld %%f15,136(%1)\n\t"
53244a4e 66
31cf3942 67 /* restore gregs and return to jmp_buf target */
00c2b3b9 68#ifdef PTR_DEMANGLE
31cf3942
SL
69 "lmg %%r6,%%r13,0(%1)\n\t"
70 "lgr %%r15,%%r5\n\t"
71 LIBC_PROBE_ASM (longjmp_target, 8@%1 -4@%0 8@%%r4)
72 "br %%r4"
305bb37e 73#else
31cf3942
SL
74 "lmg %%r6,%%r15,0(%1)\n\t"
75 LIBC_PROBE_ASM (longjmp_target, 8@%1 -4@%0 8@%%r14)
76 "br %%r14"
305bb37e 77#endif
31cf3942 78 : : "r" (r2),
00c2b3b9 79#ifdef PTR_DEMANGLE
31cf3942 80 "r" (r1), "r" (r3)
305bb37e 81#else
31cf3942 82 "a" (env)
00c2b3b9 83#endif
31cf3942 84 );
847b055c
AJ
85
86 /* Avoid `volatile function does return' warnings. */
87 for (;;);
88}