Update copyright notices with scripts/update-copyrights.
[jlayton/glibc.git] / ports / sysdeps / hppa / __longjmp.c
1 /* longjmp for PA-RISC.
2    Copyright (C) 1997-2013 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library.  If not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #include <setjmp.h>
20 #include <stdlib.h>
21
22 /* Jump to the position specified by ENV, causing the
23    setjmp call there to return VAL, or 1 if VAL is 0.  */
24 void
25 __longjmp (__jmp_buf env, int val)
26 {
27   /* We must use one of the non-callee saves registers
28      for env.  */
29   register unsigned long r26 asm ("r26") = (unsigned long)&env[0];
30
31 #ifdef CHECK_SP
32   CHECK_SP (env[0].__jmp_buf.__sp);
33 #endif
34
35   asm volatile(
36         /* Set return value.  */
37         "copy   %0, %%r28\n\t"
38         /* Load callee saves from r3 to r18.  */
39         "ldw    0(%1), %%r3\n\t"
40         "ldw    8(%1), %%r4\n\t"
41         "ldw    12(%1), %%r5\n\t"
42         "ldw    16(%1), %%r6\n\t"
43         "ldw    20(%1), %%r7\n\t"
44         "ldw    24(%1), %%r8\n\t"
45         "ldw    28(%1), %%r9\n\t"
46         "ldw    32(%1), %%r10\n\t"
47         "ldw    36(%1), %%r11\n\t"
48         "ldw    40(%1), %%r12\n\t"
49         "ldw    44(%1), %%r13\n\t"
50         "ldw    48(%1), %%r14\n\t"
51         "ldw    52(%1), %%r15\n\t"
52         "ldw    56(%1), %%r16\n\t"
53         "ldw    60(%1), %%r17\n\t"
54         "ldw    64(%1), %%r18\n\t"
55         /* Load PIC register.  */
56         "ldw    68(%1), %%r19\n\t"
57         /* Load static link register.  */
58         "ldw    72(%1), %%r27\n\t"
59         /* Load stack pointer.  */
60         "ldw    76(%1), %%r30\n\t"
61         /* Load return pointer. */
62         "ldw    80(%1), %%rp\n\t"
63         /* Ues a spare caller saves register.  */
64         "ldo    88(%1),%%r20\n\t"
65         /* Load callee saves from fr12 to fr21.  */
66         "fldds,ma 8(%%r20), %%fr12\n\t"
67         "fldds,ma 8(%%r20), %%fr13\n\t"
68         "fldds,ma 8(%%r20), %%fr14\n\t"
69         "fldds,ma 8(%%r20), %%fr15\n\t"
70         "fldds,ma 8(%%r20), %%fr16\n\t"
71         "fldds,ma 8(%%r20), %%fr17\n\t"
72         "fldds,ma 8(%%r20), %%fr18\n\t"
73         "fldds,ma 8(%%r20), %%fr19\n\t"
74         "fldds,ma 8(%%r20), %%fr20\n\t"
75         "fldds   0(%%r20), %%fr21\n\t"
76         /* Jump back to stored return address.  */
77         "bv,n   %%r0(%%r2)\n\t"
78         : /* No outputs.  */
79         : "r" (val == 0 ? 1 : val), "r" (r26)
80         : /* No point in clobbers.  */ );
81   /* Avoid `volatile function does return' warnings.  */
82   for (;;);
83 }