1/* longjmp for Nios II.
2 Copyright (C) 2015-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 License as
7 published by the Free Software Foundation; either version 2.1 of the
8 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/* __longjmp(jmpbuf, val) */
24
25ENTRY (__longjmp)
26 mov r2, r5
27 bne r5, zero, 1f
28 movi r2, 1
291:
30#ifdef PTR_DEMANGLE
31 PTR_MANGLE_GUARD (r3)
32 ldw r5, (JB_RA*4)(r4)
33 ldw r6, (JB_SP*4)(r4)
34 PTR_DEMANGLE (r5, r5, r3)
35 PTR_DEMANGLE (r6, r6, r3)
36#endif
37
38 cfi_def_cfa (r4, 0)
39 cfi_offset (r16, JB_R16*4)
40 cfi_offset (r17, JB_R17*4)
41 cfi_offset (r18, JB_R18*4)
42 cfi_offset (r19, JB_R19*4)
43 cfi_offset (r20, JB_R20*4)
44 cfi_offset (r21, JB_R21*4)
45 cfi_offset (r22, JB_R22*4)
46 cfi_offset (fp, JB_FP*4)
47#ifdef PTR_DEMANGLE
48 cfi_register (ra, r5)
49 cfi_register (sp, r7)
50#else
51 cfi_offset (ra, JB_RA*4)
52 cfi_offset (sp, JB_SP*4)
53#endif
54 ldw r16, (JB_R16*4)(r4)
55 ldw r17, (JB_R17*4)(r4)
56 ldw r18, (JB_R18*4)(r4)
57 ldw r19, (JB_R19*4)(r4)
58 ldw r20, (JB_R20*4)(r4)
59 ldw r21, (JB_R21*4)(r4)
60 ldw r22, (JB_R22*4)(r4)
61 ldw fp, (JB_FP*4)(r4)
62#ifdef PTR_DEMANGLE
63 mov ra, r5
64 mov sp, r6
65#else
66 ldw ra, (JB_RA*4)(r4)
67 ldw sp, (JB_SP*4)(r4)
68#endif
69 cfi_same_value (r16)
70 cfi_same_value (r17)
71 cfi_same_value (r18)
72 cfi_same_value (r19)
73 cfi_same_value (r20)
74 cfi_same_value (r21)
75 cfi_same_value (r22)
76 cfi_same_value (fp)
77 cfi_same_value (ra)
78 cfi_same_value (sp)
79
80 ret
81END (__longjmp)
82

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