]>
Commit | Line | Data |
---|---|---|
dff8da6b | 1 | /* Copyright (C) 1992-2024 Free Software Foundation, Inc. |
1bf0f668 | 2 | This file is part of the GNU C Library. |
92a3358c | 3 | |
1bf0f668 | 4 | The GNU C Library is free software; you can redistribute it and/or |
3214b89b 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. | |
92a3358c | 8 | |
1bf0f668 UD |
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 | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
3214b89b | 12 | Lesser General Public License for more details. |
92a3358c | 13 | |
3214b89b | 14 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff | 15 | License along with the GNU C Library. If not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
92a3358c | 17 | |
92a3358c BK |
18 | #include <setjmp.h> |
19 | #include <stdlib.h> | |
20 | ||
d14810a6 RM |
21 | #ifndef __GNUC__ |
22 | #error This file uses GNU C extensions; you must compile with GCC. | |
23 | #endif | |
24 | ||
43301bd3 | 25 | static void __attribute__ ((nomips16)) |
f1a5a0e3 | 26 | ____longjmp (__jmp_buf env_arg, int val_arg) |
92a3358c BK |
27 | { |
28 | /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before | |
29 | the hack around it); force it to use $a1 for the longjmp value. | |
30 | Without this it saves $a1 in a register which gets clobbered | |
31 | along the way. */ | |
c67273d5 | 32 | register struct __jmp_buf_internal_tag *env asm ("a0"); |
92a3358c | 33 | register int val asm ("a1"); |
6a9f82ac JM |
34 | #ifdef CHECK_SP |
35 | register long sp asm ("$29"); | |
c67273d5 | 36 | CHECK_SP (env[0].__sp, sp, long); |
6a9f82ac | 37 | #endif |
92a3358c | 38 | |
6b4d184d | 39 | #ifdef __mips_hard_float |
92a3358c BK |
40 | /* Pull back the floating point callee-saved registers. */ |
41 | asm volatile ("l.d $f20, %0" : : "m" (env[0].__fpregs[0])); | |
42 | asm volatile ("l.d $f22, %0" : : "m" (env[0].__fpregs[1])); | |
43 | asm volatile ("l.d $f24, %0" : : "m" (env[0].__fpregs[2])); | |
44 | asm volatile ("l.d $f26, %0" : : "m" (env[0].__fpregs[3])); | |
45 | asm volatile ("l.d $f28, %0" : : "m" (env[0].__fpregs[4])); | |
46 | asm volatile ("l.d $f30, %0" : : "m" (env[0].__fpregs[5])); | |
6b4d184d | 47 | #endif |
92a3358c | 48 | |
92a3358c BK |
49 | /* Get the GP. */ |
50 | asm volatile ("lw $gp, %0" : : "m" (env[0].__gp)); | |
51 | ||
52 | /* Get the callee-saved registers. */ | |
53 | asm volatile ("lw $16, %0" : : "m" (env[0].__regs[0])); | |
54 | asm volatile ("lw $17, %0" : : "m" (env[0].__regs[1])); | |
55 | asm volatile ("lw $18, %0" : : "m" (env[0].__regs[2])); | |
56 | asm volatile ("lw $19, %0" : : "m" (env[0].__regs[3])); | |
57 | asm volatile ("lw $20, %0" : : "m" (env[0].__regs[4])); | |
58 | asm volatile ("lw $21, %0" : : "m" (env[0].__regs[5])); | |
59 | asm volatile ("lw $22, %0" : : "m" (env[0].__regs[6])); | |
60 | asm volatile ("lw $23, %0" : : "m" (env[0].__regs[7])); | |
61 | ||
62 | /* Get the PC. */ | |
5b917f4e | 63 | asm volatile ("lw $25, %0" : : "m" (env[0].__pc)); |
1bf0f668 | 64 | |
a9a575e6 AJ |
65 | /* Restore the stack pointer and the FP. They have to be restored |
66 | last and in a single asm as gcc, depending on options used, may | |
67 | use either of them to access env. */ | |
68 | asm volatile ("lw $29, %0\n\t" | |
69 | "lw $30, %1\n\t" : : "m" (env[0].__sp), "m" (env[0].__fp)); | |
70 | ||
71 | /* Give setjmp 1 if given a 0, or what they gave us if non-zero. */ | |
92a3358c BK |
72 | if (val == 0) |
73 | asm volatile ("li $2, 1"); | |
74 | else | |
75 | asm volatile ("move $2, %0" : : "r" (val)); | |
76 | ||
5b917f4e | 77 | asm volatile ("jr $25"); |
92a3358c | 78 | |
f8182559 AJ |
79 | /* Avoid `volatile function does return' warnings. */ |
80 | for (;;); | |
92a3358c | 81 | } |
43301bd3 | 82 | |
0c096dcf JM |
83 | /* Not using strong_alias because the nomips16 attribute cannot be |
84 | copied from ____longjmp to __longjmp, because of the | |
85 | architecture-independent declaration of __longjmp without the | |
86 | attribute and compiler errors for such attributes not being the | |
87 | same on all declarations. */ | |
88 | extern __typeof (____longjmp) __longjmp __attribute__ ((alias ("____longjmp"))); |