Back to index

glibc  2.9
setjmp_aux.c
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1997, 2003, 2004 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Brendan Kehoe (brendan@zen.org).
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <setjmp.h>
00021 #include <sgidefs.h>
00022 
00023 /* This function is only called via the assembly language routine
00024    __sigsetjmp, which arranges to pass in the stack pointer and the frame
00025    pointer.  We do things this way because it's difficult to reliably
00026    access them in C.  */
00027 
00028 int
00029 __sigsetjmp_aux (jmp_buf env, int savemask, long long sp, long long fp,
00030                long long gp)
00031 {
00032 #ifdef __mips_hard_float
00033   /* Store the floating point callee-saved registers...  */
00034 #if _MIPS_SIM == _ABI64
00035   asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
00036   asm volatile ("s.d $f25, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
00037   asm volatile ("s.d $f26, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
00038   asm volatile ("s.d $f27, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[3]));
00039   asm volatile ("s.d $f28, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[4]));
00040   asm volatile ("s.d $f29, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
00041   asm volatile ("s.d $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[6]));
00042   asm volatile ("s.d $f31, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[7]));
00043 #else
00044   asm volatile ("s.d $f20, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
00045   asm volatile ("s.d $f22, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
00046   asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
00047   asm volatile ("s.d $f26, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[3]));
00048   asm volatile ("s.d $f28, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[4]));
00049   asm volatile ("s.d $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
00050 #endif
00051 #endif
00052 
00053   /* .. and the PC;  */
00054   asm volatile ("sd $31, %0" : : "m" (env[0].__jmpbuf[0].__pc));
00055 
00056   /* .. and the stack pointer;  */
00057   env[0].__jmpbuf[0].__sp = sp;
00058 
00059   /* .. and the FP; it'll be in s8. */
00060   env[0].__jmpbuf[0].__fp = fp;
00061 
00062   /* .. and the GP; */
00063   env[0].__jmpbuf[0].__gp = gp;
00064 
00065   /* .. and the callee-saved registers; */
00066   asm volatile ("sd $16, %0" : : "m" (env[0].__jmpbuf[0].__regs[0]));
00067   asm volatile ("sd $17, %0" : : "m" (env[0].__jmpbuf[0].__regs[1]));
00068   asm volatile ("sd $18, %0" : : "m" (env[0].__jmpbuf[0].__regs[2]));
00069   asm volatile ("sd $19, %0" : : "m" (env[0].__jmpbuf[0].__regs[3]));
00070   asm volatile ("sd $20, %0" : : "m" (env[0].__jmpbuf[0].__regs[4]));
00071   asm volatile ("sd $21, %0" : : "m" (env[0].__jmpbuf[0].__regs[5]));
00072   asm volatile ("sd $22, %0" : : "m" (env[0].__jmpbuf[0].__regs[6]));
00073   asm volatile ("sd $23, %0" : : "m" (env[0].__jmpbuf[0].__regs[7]));
00074 
00075 #ifdef __mips_hard_float
00076   /* .. and finally get and reconstruct the floating point csr.  */
00077   asm ("cfc1 %0, $31" : "=r" (env[0].__jmpbuf[0].__fpc_csr));
00078 #endif
00079 
00080   /* Save the signal mask if requested.  */
00081   return __sigjmp_save (env, savemask);
00082 }