|
Packit Service |
82fcde |
/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
Contributed by Brendan Kehoe (brendan@zen.org).
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library. If not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <setjmp.h>
|
|
Packit Service |
82fcde |
#include <stdlib.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef __GNUC__
|
|
Packit Service |
82fcde |
#error This file uses GNU C extensions; you must compile with GCC.
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static void __attribute__ ((nomips16))
|
|
Packit Service |
82fcde |
____longjmp (__jmp_buf env_arg, int val_arg)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before
|
|
Packit Service |
82fcde |
the hack around it); force it to use $a1 for the longjmp value.
|
|
Packit Service |
82fcde |
Without this it saves $a1 in a register which gets clobbered
|
|
Packit Service |
82fcde |
along the way. */
|
|
Packit Service |
82fcde |
register struct __jmp_buf_internal_tag *env asm ("a0");
|
|
Packit Service |
82fcde |
register int val asm ("a1");
|
|
Packit Service |
82fcde |
#ifdef CHECK_SP
|
|
Packit Service |
82fcde |
register long sp asm ("$29");
|
|
Packit Service |
82fcde |
CHECK_SP (env[0].__sp, sp, long);
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __mips_hard_float
|
|
Packit Service |
82fcde |
/* Pull back the floating point callee-saved registers. */
|
|
Packit Service |
82fcde |
asm volatile ("l.d $f20, %0" : : "m" (env[0].__fpregs[0]));
|
|
Packit Service |
82fcde |
asm volatile ("l.d $f22, %0" : : "m" (env[0].__fpregs[1]));
|
|
Packit Service |
82fcde |
asm volatile ("l.d $f24, %0" : : "m" (env[0].__fpregs[2]));
|
|
Packit Service |
82fcde |
asm volatile ("l.d $f26, %0" : : "m" (env[0].__fpregs[3]));
|
|
Packit Service |
82fcde |
asm volatile ("l.d $f28, %0" : : "m" (env[0].__fpregs[4]));
|
|
Packit Service |
82fcde |
asm volatile ("l.d $f30, %0" : : "m" (env[0].__fpregs[5]));
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Get the GP. */
|
|
Packit Service |
82fcde |
asm volatile ("lw $gp, %0" : : "m" (env[0].__gp));
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Get the callee-saved registers. */
|
|
Packit Service |
82fcde |
asm volatile ("lw $16, %0" : : "m" (env[0].__regs[0]));
|
|
Packit Service |
82fcde |
asm volatile ("lw $17, %0" : : "m" (env[0].__regs[1]));
|
|
Packit Service |
82fcde |
asm volatile ("lw $18, %0" : : "m" (env[0].__regs[2]));
|
|
Packit Service |
82fcde |
asm volatile ("lw $19, %0" : : "m" (env[0].__regs[3]));
|
|
Packit Service |
82fcde |
asm volatile ("lw $20, %0" : : "m" (env[0].__regs[4]));
|
|
Packit Service |
82fcde |
asm volatile ("lw $21, %0" : : "m" (env[0].__regs[5]));
|
|
Packit Service |
82fcde |
asm volatile ("lw $22, %0" : : "m" (env[0].__regs[6]));
|
|
Packit Service |
82fcde |
asm volatile ("lw $23, %0" : : "m" (env[0].__regs[7]));
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Get the PC. */
|
|
Packit Service |
82fcde |
asm volatile ("lw $25, %0" : : "m" (env[0].__pc));
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Restore the stack pointer and the FP. They have to be restored
|
|
Packit Service |
82fcde |
last and in a single asm as gcc, depending on options used, may
|
|
Packit Service |
82fcde |
use either of them to access env. */
|
|
Packit Service |
82fcde |
asm volatile ("lw $29, %0\n\t"
|
|
Packit Service |
82fcde |
"lw $30, %1\n\t" : : "m" (env[0].__sp), "m" (env[0].__fp));
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Give setjmp 1 if given a 0, or what they gave us if non-zero. */
|
|
Packit Service |
82fcde |
if (val == 0)
|
|
Packit Service |
82fcde |
asm volatile ("li $2, 1");
|
|
Packit Service |
82fcde |
else
|
|
Packit Service |
82fcde |
asm volatile ("move $2, %0" : : "r" (val));
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
asm volatile ("jr $25");
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Avoid `volatile function does return' warnings. */
|
|
Packit Service |
82fcde |
for (;;);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
strong_alias (____longjmp, __longjmp);
|