1 | /* setjmp for Nios II. |
2 | Copyright (C) 1991-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 <jmpbuf-offsets.h> |
22 | |
23 | .text |
24 | ENTRY(setjmp) |
25 | movi r5, 1 |
26 | br __sigsetjmp |
27 | END(setjmp) |
28 | |
29 | ENTRY(_setjmp) |
30 | mov r5, zero |
31 | br __sigsetjmp |
32 | END(_setjmp) |
33 | libc_hidden_def (_setjmp) |
34 | |
35 | /* Save the current program position in ENV and return 0. */ |
36 | ENTRY(__sigsetjmp) |
37 | #ifdef PTR_MANGLE |
38 | PTR_MANGLE_GUARD (r9) |
39 | #endif |
40 | stw r16, (JB_R16*4)(r4) |
41 | stw r17, (JB_R17*4)(r4) |
42 | stw r18, (JB_R18*4)(r4) |
43 | stw r19, (JB_R19*4)(r4) |
44 | stw r20, (JB_R20*4)(r4) |
45 | stw r21, (JB_R21*4)(r4) |
46 | stw r22, (JB_R22*4)(r4) |
47 | stw fp, (JB_FP*4)(r4) |
48 | #ifdef PTR_MANGLE |
49 | PTR_MANGLE (r6, ra, r9) |
50 | PTR_MANGLE (r7, sp, r9) |
51 | stw r6, (JB_RA*4)(r4) |
52 | stw r7, (JB_SP*4)(r4) |
53 | #else |
54 | stw ra, (JB_RA*4)(r4) |
55 | stw sp, (JB_SP*4)(r4) |
56 | #endif |
57 | #if IS_IN (rtld) |
58 | /* In ld.so we never save the signal mask. */ |
59 | mov r2, zero |
60 | ret |
61 | #else |
62 | /* Save the signal mask if requested. */ |
63 | #if defined(__PIC__) || defined(PIC) |
64 | nextpc r2 |
65 | 1: movhi r3, %hiadj(__sigjmp_save - 1b) |
66 | addi r3, r3, %lo(__sigjmp_save - 1b) |
67 | add r2, r2, r3 |
68 | jmp r2 |
69 | #else |
70 | jmpi __sigjmp_save |
71 | #endif |
72 | #endif |
73 | END (__sigsetjmp) |
74 | libc_hidden_def (__sigsetjmp) |
75 | |