Back to index

glibc  2.9
__longjmp.c
Go to the documentation of this file.
00001 /* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <setjmp.h>
00020 #include <stdlib.h>
00021 
00022 /* Jump to the position specified by ENV, causing the
00023    setjmp call there to return VAL, or 1 if VAL is 0.  */
00024 void
00025 __longjmp (__jmp_buf env, int val)
00026 {
00027   /* This restores the FP and SP that setjmp's caller had,
00028      and puts the return address into A0 and VAL into D0. */
00029 
00030 #if    defined(__HAVE_68881__) || defined(__HAVE_FPU__)
00031   /* Restore the floating-point registers.  */
00032   asm volatile("fmovem%.x %0, %/fp0-%/fp7" :
00033               /* No outputs.  */ : "g" (env[0].__fpregs[0]));
00034 #elif defined (__mcffpu__)
00035   asm volatile("fmovem %0, %/fp0-%/fp7" :
00036               /* No outputs.  */ : "m" (env[0].__fpregs[0]));
00037 #endif
00038 
00039   /* Put VAL in D0.  */
00040   asm volatile("move%.l %0, %/d0" : /* No outputs.  */ :
00041               "g" (val == 0 ? 1 : val) : "d0");
00042 
00043   asm volatile(/* Restore the data and address registers.  */
00044               "movem%.l %0, %/d1-%/d7/%/a0-%/a7\n"
00045               /* Return to setjmp's caller.  */
00046 #ifdef __motorola__
00047               "jmp (%/a0)"
00048 #else
00049               "jmp %/a0@"
00050 #endif
00051               : /* No outputs.  */ : "g" (env[0].__dregs[0])
00052               /* We don't bother with the clobbers,
00053                 because this code always jumps out anyway.  */
00054               );
00055 
00056   /* Avoid `volatile function does return' warnings.  */
00057   for (;;);
00058 }