1 /* longjmp for PA-RISC.
2    Copyright (C) 1997-2022 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    <https://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
__longjmp(__jmp_buf env,int val)25 __longjmp (__jmp_buf env, int val)
26 {
27 #ifdef CHECK_SP
28   CHECK_SP (env[0].__jmp_buf.__sp);
29 #endif
30 
31   /* We must use one of the non-callee saves registers
32      for env.  */
33   register unsigned long r26 asm ("r26") = (unsigned long)&env[0];
34   register unsigned long r25 asm ("r25") = (unsigned long)(val == 0 ? 1 : val);
35 
36   asm volatile(
37 	/* Set return value.  */
38 	"copy	%0, %%r28\n\t"
39 	/* Load callee saves from r3 to r18.  */
40 	"ldw	0(%1), %%r3\n\t"
41 	"ldw	8(%1), %%r4\n\t"
42 	"ldw	12(%1), %%r5\n\t"
43 	"ldw	16(%1), %%r6\n\t"
44 	"ldw	20(%1), %%r7\n\t"
45 	"ldw	24(%1), %%r8\n\t"
46 	"ldw	28(%1), %%r9\n\t"
47 	"ldw	32(%1), %%r10\n\t"
48 	"ldw	36(%1), %%r11\n\t"
49 	"ldw	40(%1), %%r12\n\t"
50 	"ldw	44(%1), %%r13\n\t"
51 	"ldw	48(%1), %%r14\n\t"
52 	"ldw	52(%1), %%r15\n\t"
53 	"ldw	56(%1), %%r16\n\t"
54 	"ldw	60(%1), %%r17\n\t"
55 	"ldw	64(%1), %%r18\n\t"
56 	/* Load PIC register.  */
57 	"ldw	68(%1), %%r19\n\t"
58 	/* Load static link register.  */
59 	"ldw	72(%1), %%r27\n\t"
60 	/* Load stack pointer.  */
61 	"ldw	76(%1), %%r30\n\t"
62 	/* Load return pointer. */
63 	"ldw	80(%1), %%rp\n\t"
64 	/* Ues a spare caller saves register.  */
65 	"ldo	88(%1),%%r25\n\t"
66 	/* Load callee saves from fr12 to fr21.  */
67 	"fldds,ma 8(%%r25), %%fr12\n\t"
68 	"fldds,ma 8(%%r25), %%fr13\n\t"
69 	"fldds,ma 8(%%r25), %%fr14\n\t"
70 	"fldds,ma 8(%%r25), %%fr15\n\t"
71 	"fldds,ma 8(%%r25), %%fr16\n\t"
72 	"fldds,ma 8(%%r25), %%fr17\n\t"
73 	"fldds,ma 8(%%r25), %%fr18\n\t"
74 	"fldds,ma 8(%%r25), %%fr19\n\t"
75 	"fldds,ma 8(%%r25), %%fr20\n\t"
76 	"fldds	 0(%%r25), %%fr21\n\t"
77 	/* Jump back to stored return address.  */
78 	"bv,n	%%r0(%%r2)\n\t"
79 	: /* No outputs.  */
80 	: "r" (r25), "r" (r26)
81 	: /* No point in clobbers.  */ );
82 
83   /* Avoid `volatile function does return' warnings.  */
84   for (;;);
85 }
86