1/* longjmp.
2 Copyright (C) 2022-2024 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#include <sysdep.h>
20#include <pointer_guard.h>
21#include <sys/asm.h>
22
23ENTRY (__longjmp)
24#ifdef PTR_MANGLE
25 REG_L t0, a0, 0*SZREG
26 PTR_DEMANGLE (ra, t0, t1)
27 REG_L t0, a0, 1*SZREG
28 PTR_DEMANGLE2 (sp, t0, t1)
29#else
30 REG_L ra, a0, 0*SZREG
31 REG_L sp, a0, 1*SZREG
32#endif
33 REG_L x, a0, 2*SZREG
34 REG_L fp, a0, 3*SZREG
35 REG_L s0, a0, 4*SZREG
36 REG_L s1, a0, 5*SZREG
37 REG_L s2, a0, 6*SZREG
38 REG_L s3, a0, 7*SZREG
39 REG_L s4, a0, 8*SZREG
40 REG_L s5, a0, 9*SZREG
41 REG_L s6, a0, 10*SZREG
42 REG_L s7, a0, 11*SZREG
43 REG_L s8, a0, 12*SZREG
44
45#ifndef __loongarch_soft_float
46 FREG_L fs0, a0, 13*SZREG + 0*SZFREG
47 FREG_L fs1, a0, 13*SZREG + 1*SZFREG
48 FREG_L fs2, a0, 13*SZREG + 2*SZFREG
49 FREG_L fs3, a0, 13*SZREG + 3*SZFREG
50 FREG_L fs4, a0, 13*SZREG + 4*SZFREG
51 FREG_L fs5, a0, 13*SZREG + 5*SZFREG
52 FREG_L fs6, a0, 13*SZREG + 6*SZFREG
53 FREG_L fs7, a0, 13*SZREG + 7*SZFREG
54#endif
55
56 sltui a0, a1, 1
57 ADD a0, a0, a1 # a0 = (a1 == 0) ? 1 : a1
58 jirl zero, ra, 0
59
60END (__longjmp)
61

source code of glibc/sysdeps/loongarch/__longjmp.S