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