yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | /* Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005 |
| 2 | Free Software Foundation, Inc. |
| 3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com>. |
| 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, write to the Free |
| 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 18 | 02111-1307 USA. |
| 19 | |
| 20 | The layout of the jmp_buf is as follows. This is subject to change |
| 21 | and user-code should never depend on the particular layout of |
| 22 | jmp_buf! |
| 23 | |
| 24 | |
| 25 | offset: description: |
| 26 | ------- ------------ |
| 27 | 0x000 stack pointer (r12) ; unchangeable (see _JMPBUF_UNWINDS) |
| 28 | 0x008 r1 (gp) |
| 29 | 0x010 caller's unat |
| 30 | 0x018 fpsr |
| 31 | 0x020 r4 |
| 32 | 0x028 r5 |
| 33 | 0x030 r6 |
| 34 | 0x038 r7 |
| 35 | 0x040 rp (b0) |
| 36 | 0x048 b1 |
| 37 | 0x050 b2 |
| 38 | 0x058 b3 |
| 39 | 0x060 b4 |
| 40 | 0x068 b5 |
| 41 | 0x070 ar.pfs |
| 42 | 0x078 ar.lc |
| 43 | 0x080 pr |
| 44 | 0x088 ar.bsp ; unchangeable (see __longjmp.S) |
| 45 | 0x090 ar.unat |
| 46 | 0x098 &__jmp_buf ; address of the jmpbuf (needed to locate NaT bits in unat) |
| 47 | 0x0a0 f2 |
| 48 | 0x0b0 f3 |
| 49 | 0x0c0 f4 |
| 50 | 0x0d0 f5 |
| 51 | 0x0e0 f16 |
| 52 | 0x0f0 f17 |
| 53 | 0x100 f18 |
| 54 | 0x110 f19 |
| 55 | 0x120 f20 |
| 56 | 0x130 f21 |
| 57 | 0x130 f22 |
| 58 | 0x140 f23 |
| 59 | 0x150 f24 |
| 60 | 0x160 f25 |
| 61 | 0x170 f26 |
| 62 | 0x180 f27 |
| 63 | 0x190 f28 |
| 64 | 0x1a0 f29 |
| 65 | 0x1b0 f30 |
| 66 | 0x1c0 f31 */ |
| 67 | |
| 68 | #include "sysdep.h" |
| 69 | #include <features.h> |
| 70 | |
| 71 | /* The following two entry points are the traditional entry points: */ |
| 72 | |
| 73 | LEAF(setjmp) |
| 74 | alloc r8=ar.pfs,2,0,0,0 |
| 75 | mov in1=1 |
| 76 | br.cond.sptk.many _GI___sigsetjmp |
| 77 | END(setjmp) |
| 78 | |
| 79 | LEAF(_setjmp) |
| 80 | alloc r8=ar.pfs,2,0,0,0 |
| 81 | mov in1=0 |
| 82 | br.cond.sptk.many _GI___sigsetjmp |
| 83 | END(_setjmp) |
| 84 | libc_hidden_def (_setjmp) |
| 85 | |
| 86 | /* __sigsetjmp(__jmp_buf buf, int savemask) */ |
| 87 | |
| 88 | ENTRY(__sigsetjmp) |
| 89 | .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2) |
| 90 | alloc loc1=ar.pfs,2,5,2,0 |
| 91 | .save ar.unat, loc2 |
| 92 | mov loc2=ar.unat |
| 93 | ;; |
| 94 | mov r17=ar.fpsr |
| 95 | mov r2=in0 |
| 96 | add r3=8,in0 |
| 97 | ;; |
| 98 | .mem.offset 8,0; st8.spill.nta [r2]=sp,16 /* r12 (sp) */ |
| 99 | .mem.offset 0,0; st8.spill.nta [r3]=gp,16 /* r1 (gp) */ |
| 100 | ;; |
| 101 | st8.nta [r2]=loc2,16 /* save caller's unat */ |
| 102 | st8.nta [r3]=r17,16 /* save fpsr */ |
| 103 | add r8=0xa0,in0 |
| 104 | ;; |
| 105 | .mem.offset 8,0; st8.spill.nta [r2]=r4,16 /* r4 */ |
| 106 | .mem.offset 0,0; st8.spill.nta [r3]=r5,16 /* r5 */ |
| 107 | add r9=0xb0,in0 |
| 108 | ;; |
| 109 | stf.spill.nta [r8]=f2,32 |
| 110 | stf.spill.nta [r9]=f3,32 |
| 111 | mov loc0=rp |
| 112 | .body |
| 113 | ;; |
| 114 | stf.spill.nta [r8]=f4,32 |
| 115 | stf.spill.nta [r9]=f5,32 |
| 116 | mov r17=b1 |
| 117 | ;; |
| 118 | stf.spill.nta [r8]=f16,32 |
| 119 | stf.spill.nta [r9]=f17,32 |
| 120 | mov r18=b2 |
| 121 | ;; |
| 122 | stf.spill.nta [r8]=f18,32 |
| 123 | stf.spill.nta [r9]=f19,32 |
| 124 | mov r19=b3 |
| 125 | ;; |
| 126 | stf.spill.nta [r8]=f20,32 |
| 127 | stf.spill.nta [r9]=f21,32 |
| 128 | mov r20=b4 |
| 129 | ;; |
| 130 | stf.spill.nta [r8]=f22,32 |
| 131 | stf.spill.nta [r9]=f23,32 |
| 132 | mov r21=b5 |
| 133 | ;; |
| 134 | stf.spill.nta [r8]=f24,32 |
| 135 | stf.spill.nta [r9]=f25,32 |
| 136 | mov r22=ar.lc |
| 137 | ;; |
| 138 | stf.spill.nta [r8]=f26,32 |
| 139 | stf.spill.nta [r9]=f27,32 |
| 140 | mov r24=pr |
| 141 | ;; |
| 142 | stf.spill.nta [r8]=f28,32 |
| 143 | stf.spill.nta [r9]=f29,32 |
| 144 | ;; |
| 145 | stf.spill.nta [r8]=f30 |
| 146 | stf.spill.nta [r9]=f31 |
| 147 | |
| 148 | .mem.offset 8,0; st8.spill.nta [r2]=r6,16 /* r6 */ |
| 149 | .mem.offset 0,0; st8.spill.nta [r3]=r7,16 /* r7 */ |
| 150 | ;; |
| 151 | mov r23=ar.bsp |
| 152 | mov r25=ar.unat |
| 153 | mov out0=in0 |
| 154 | |
| 155 | st8.nta [r2]=loc0,16 /* b0 */ |
| 156 | st8.nta [r3]=r17,16 /* b1 */ |
| 157 | mov out1=in1 |
| 158 | ;; |
| 159 | st8.nta [r2]=r18,16 /* b2 */ |
| 160 | st8.nta [r3]=r19,16 /* b3 */ |
| 161 | ;; |
| 162 | st8.nta [r2]=r20,16 /* b4 */ |
| 163 | st8.nta [r3]=r21,16 /* b5 */ |
| 164 | ;; |
| 165 | st8.nta [r2]=loc1,16 /* ar.pfs */ |
| 166 | st8.nta [r3]=r22,16 /* ar.lc */ |
| 167 | ;; |
| 168 | st8.nta [r2]=r24,16 /* pr */ |
| 169 | st8.nta [r3]=r23,16 /* ar.bsp */ |
| 170 | ;; |
| 171 | st8.nta [r2]=r25 /* ar.unat */ |
| 172 | st8.nta [r3]=in0 /* &__jmp_buf */ |
| 173 | #if defined NOT_IN_libc && defined IS_IN_rtld |
| 174 | /* In ld.so we never save the signal mask. */ |
| 175 | ;; |
| 176 | #else |
| 177 | br.call.dpnt.few rp=__sigjmp_save |
| 178 | #endif |
| 179 | .ret0: /* force a new bundle ::q */ |
| 180 | mov.m ar.unat=loc2 /* restore caller's unat */ |
| 181 | mov rp=loc0 |
| 182 | mov ar.pfs=loc1 |
| 183 | mov r8=0 |
| 184 | ret |
| 185 | END(__sigsetjmp) |
| 186 | strong_alias(__sigsetjmp, _GI___sigsetjmp) |
| 187 | |
| 188 | weak_extern(_setjmp) |
| 189 | weak_extern(setjmp) |