]>
sourceware.org Git - glibc.git/blob - sysdeps/mips/__longjmp.c
1 /* Copyright (C) 1992-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
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.
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
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <https://www.gnu.org/licenses/>. */
22 #error This file uses GNU C extensions; you must compile with GCC.
25 static void __attribute__ ((nomips16
))
26 ____longjmp (__jmp_buf env_arg
, int val_arg
)
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
32 register struct __jmp_buf_internal_tag
*env
asm ("a0");
33 register int val
asm ("a1");
35 register long sp
asm ("$29");
36 CHECK_SP (env
[0].__sp
, sp
, long);
39 #ifdef __mips_hard_float
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]));
50 asm volatile ("lw $gp, %0" : : "m" (env
[0].__gp
));
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]));
63 asm volatile ("lw $25, %0" : : "m" (env
[0].__pc
));
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
));
71 /* Give setjmp 1 if given a 0, or what they gave us if non-zero. */
73 asm volatile ("li $2, 1");
75 asm volatile ("move $2, %0" : : "r" (val
));
77 asm volatile ("jr $25");
79 /* Avoid `volatile function does return' warnings. */
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")));
This page took 0.045796 seconds and 6 git commands to generate.