Back to index

glibc  2.9
__longjmp.c
Go to the documentation of this file.
00001 /* Copyright (C) 2001, 2005 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
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 <errno.h>
00021 #include <sysdep.h>
00022 #include <setjmp.h>
00023 #include <bits/setjmp.h>
00024 #include <stdlib.h>
00025 #include <unistd.h>
00026 
00027 /* Jump to the position specified by ENV, causing the
00028    setjmp call there to return VAL, or 1 if VAL is 0.  */
00029 void
00030 __longjmp (__jmp_buf env, int val)
00031 {
00032   register long int r2 __asm ("%r2") = val == 0 ? 1 : val;
00033 #ifdef PTR_DEMANGLE
00034   register uintptr_t r3 __asm ("%r3") = THREAD_GET_POINTER_GUARD ();
00035   register void *r1 __asm ("%r1") = (void *) env;
00036 #endif
00037   /* Restore registers and jump back.  */
00038   asm volatile ("ld   %%f7,104(%1)\n\t"
00039               "ld   %%f5,96(%1)\n\t"
00040               "ld   %%f3,88(%1)\n\t"
00041               "ld   %%f1,80(%1)\n\t"
00042 #ifdef PTR_DEMANGLE
00043               "lmg  %%r6,%%r13,0(%1)\n\t"
00044               "lmg  %%r4,%%r5,64(%1)\n\t"
00045               "xgr  %%r4,%2\n\t"
00046               "xgr  %%r5,%2\n\t"
00047               "lgr  %%r15,%%r5\n\t"
00048               "br   %%r4"
00049 #else
00050               "lmg  %%r6,%%r15,0(%1)\n\t"
00051               "br   %%r14"
00052 #endif
00053               : : "r" (r2),
00054 #ifdef PTR_DEMANGLE
00055                   "r" (r1), "r" (r3)
00056 #else
00057                   "a" (env)
00058 #endif
00059               );
00060 
00061   /* Avoid `volatile function does return' warnings.  */
00062   for (;;);
00063 }