Back to index

glibc  2.9
setjmp_aux.c
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1997, 2000, 2002, 2003 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 
00022 /* This function is only called via the assembly language routine
00023    __sigsetjmp, which arranges to pass in the stack pointer and the frame
00024    pointer.  We do things this way because it's difficult to reliably
00025    access them in C.  */
00026 
00027 int
00028 __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
00029 {
00030 #ifdef __mips_hard_float
00031   /* Store the floating point callee-saved registers...  */
00032   asm volatile ("s.d $f20, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
00033   asm volatile ("s.d $f22, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
00034   asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
00035   asm volatile ("s.d $f26, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[3]));
00036   asm volatile ("s.d $f28, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[4]));
00037   asm volatile ("s.d $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
00038 #endif
00039 
00040   /* .. and the PC;  */
00041   asm volatile ("sw $31, %0" : : "m" (env[0].__jmpbuf[0].__pc));
00042 
00043   /* .. and the stack pointer;  */
00044   env[0].__jmpbuf[0].__sp = (void *) sp;
00045 
00046   /* .. and the FP; it'll be in s8. */
00047   env[0].__jmpbuf[0].__fp = (void *) fp;
00048 
00049   /* .. and the GP; */
00050   asm volatile ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
00051 
00052   /* .. and the callee-saved registers; */
00053   asm volatile ("sw $16, %0" : : "m" (env[0].__jmpbuf[0].__regs[0]));
00054   asm volatile ("sw $17, %0" : : "m" (env[0].__jmpbuf[0].__regs[1]));
00055   asm volatile ("sw $18, %0" : : "m" (env[0].__jmpbuf[0].__regs[2]));
00056   asm volatile ("sw $19, %0" : : "m" (env[0].__jmpbuf[0].__regs[3]));
00057   asm volatile ("sw $20, %0" : : "m" (env[0].__jmpbuf[0].__regs[4]));
00058   asm volatile ("sw $21, %0" : : "m" (env[0].__jmpbuf[0].__regs[5]));
00059   asm volatile ("sw $22, %0" : : "m" (env[0].__jmpbuf[0].__regs[6]));
00060   asm volatile ("sw $23, %0" : : "m" (env[0].__jmpbuf[0].__regs[7]));
00061 
00062 #ifdef __mips_hard_float
00063   /* .. and finally get and reconstruct the floating point csr.  */
00064   asm ("cfc1 %0, $31" : "=r" (env[0].__jmpbuf[0].__fpc_csr));
00065 #endif
00066 
00067   /* Save the signal mask if requested.  */
00068   return __sigjmp_save (env, savemask);
00069 }