Back to index

glibc  2.9
__longjmp.c
Go to the documentation of this file.
00001 /* Copyright (C) 2000, 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 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   %%f6,48(%1)\n\t"
00039               "ld   %%f4,40(%1)\n\t"
00040 #ifdef PTR_DEMANGLE
00041               "lm   %%r6,%%r13,0(%1)\n\t"
00042               "lm   %%r4,%%r5,32(%1)\n\t"
00043               "xr   %%r4,%2\n\t"
00044               "xr   %%r5,%2\n\t"
00045               "lr   %%r15,%%r5\n\t"
00046               "br   %%r4"
00047 #else
00048               "lm   %%r6,%%r15,0(%1)\n\t"
00049               "br   %%r14"
00050 #endif
00051               : : "r" (r2),
00052 #ifdef PTR_DEMANGLE
00053                   "r" (r1), "r" (r3)
00054 #else
00055                   "a" (env)
00056 #endif
00057               );
00058 
00059   /* Avoid `volatile function does return' warnings.  */
00060   for (;;);
00061 }