1/* setjmp for LoongArch.
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 (_setjmp)
24 li.w a1,0
25 b HIDDEN_JUMPTARGET (__sigsetjmp)
26END (_setjmp)
27
28ENTRY (setjmp)
29 li.w a1,1
30END (setjmp)
31
32ENTRY (__sigsetjmp)
33#ifdef PTR_MANGLE
34 PTR_MANGLE (t0, ra, t1)
35 REG_S t0, a0, 0*SZREG
36 PTR_MANGLE2 (t0, sp, t1)
37 REG_S t0, a0, 1*SZREG
38#else
39 REG_S ra, a0, 0*SZREG
40 REG_S sp, a0, 1*SZREG
41#endif
42 REG_S x, a0, 2*SZREG
43 REG_S fp, a0, 3*SZREG
44 REG_S s0, a0, 4*SZREG
45 REG_S s1, a0, 5*SZREG
46 REG_S s2, a0, 6*SZREG
47 REG_S s3, a0, 7*SZREG
48 REG_S s4, a0, 8*SZREG
49 REG_S s5, a0, 9*SZREG
50 REG_S s6, a0, 10*SZREG
51 REG_S s7, a0, 11*SZREG
52 REG_S s8, a0, 12*SZREG
53
54#ifndef __loongarch_soft_float
55 FREG_S fs0, a0, 13*SZREG + 0*SZFREG
56 FREG_S fs1, a0, 13*SZREG + 1*SZFREG
57 FREG_S fs2, a0, 13*SZREG + 2*SZFREG
58 FREG_S fs3, a0, 13*SZREG + 3*SZFREG
59 FREG_S fs4, a0, 13*SZREG + 4*SZFREG
60 FREG_S fs5, a0, 13*SZREG + 5*SZFREG
61 FREG_S fs6, a0, 13*SZREG + 6*SZFREG
62 FREG_S fs7, a0, 13*SZREG + 7*SZFREG
63#endif
64
65#if !IS_IN (libc) && IS_IN(rtld)
66 li.w v0, 0
67 jirl zero, ra, 0
68#else
69 b __sigjmp_save
70#endif
71END (__sigsetjmp)
72
73hidden_def (__sigsetjmp)
74weak_alias (_setjmp, __GI__setjmp)
75

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