Blame sysdeps/mips/setjmp_aux.c

Packit 6c4009
/* Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Brendan Kehoe (brendan@zen.org).
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <setjmp.h>
Packit 6c4009
Packit 6c4009
/* This function is only called via the assembly language routine
Packit 6c4009
   __sigsetjmp, which arranges to pass in the stack pointer and the frame
Packit 6c4009
   pointer.  We do things this way because it's difficult to reliably
Packit 6c4009
   access them in C.  */
Packit 6c4009
Packit 6c4009
/* Stack protection is disabled to avoid changing s0 (or any other
Packit 6c4009
   caller-save register) before storing it to environment.
Packit 6c4009
   See BZ #22624.  */
Packit 6c4009
Packit 6c4009
int __attribute__ ((nomips16))
Packit 6c4009
inhibit_stack_protector
Packit 6c4009
__sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
Packit 6c4009
{
Packit 6c4009
#ifdef __mips_hard_float
Packit 6c4009
  /* Store the floating point callee-saved registers...  */
Packit 6c4009
  asm volatile ("s.d $f20, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
Packit 6c4009
  asm volatile ("s.d $f22, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
Packit 6c4009
  asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
Packit 6c4009
  asm volatile ("s.d $f26, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[3]));
Packit 6c4009
  asm volatile ("s.d $f28, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[4]));
Packit 6c4009
  asm volatile ("s.d $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
  /* .. and the PC;  */
Packit 6c4009
  asm volatile ("sw $31, %0" : : "m" (env[0].__jmpbuf[0].__pc));
Packit 6c4009
Packit 6c4009
  /* .. and the stack pointer;  */
Packit 6c4009
  env[0].__jmpbuf[0].__sp = (void *) sp;
Packit 6c4009
Packit 6c4009
  /* .. and the FP; it'll be in s8. */
Packit 6c4009
  env[0].__jmpbuf[0].__fp = (void *) fp;
Packit 6c4009
Packit 6c4009
  /* .. and the GP; */
Packit 6c4009
  asm volatile ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
Packit 6c4009
Packit 6c4009
  /* .. and the callee-saved registers; */
Packit 6c4009
  asm volatile ("sw $16, %0" : : "m" (env[0].__jmpbuf[0].__regs[0]));
Packit 6c4009
  asm volatile ("sw $17, %0" : : "m" (env[0].__jmpbuf[0].__regs[1]));
Packit 6c4009
  asm volatile ("sw $18, %0" : : "m" (env[0].__jmpbuf[0].__regs[2]));
Packit 6c4009
  asm volatile ("sw $19, %0" : : "m" (env[0].__jmpbuf[0].__regs[3]));
Packit 6c4009
  asm volatile ("sw $20, %0" : : "m" (env[0].__jmpbuf[0].__regs[4]));
Packit 6c4009
  asm volatile ("sw $21, %0" : : "m" (env[0].__jmpbuf[0].__regs[5]));
Packit 6c4009
  asm volatile ("sw $22, %0" : : "m" (env[0].__jmpbuf[0].__regs[6]));
Packit 6c4009
  asm volatile ("sw $23, %0" : : "m" (env[0].__jmpbuf[0].__regs[7]));
Packit 6c4009
Packit 6c4009
  /* Save the signal mask if requested.  */
Packit 6c4009
  return __sigjmp_save (env, savemask);
Packit 6c4009
}