2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / alpha / rt_sigaction.S
blobe27949feff41a4fb0d6bdd164ca41f0439dc903b
1 /* Copyright (C) 1998, 2003, 2004 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Richard Henderson <rth@cygnus.com>, 1998
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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
20 #include <sysdep.h>
22 /* On Alpha we desparately want to avoid having to issue an imb.  Ordinarily
23    the kernel would have to issue one after setting up the signal return
24    stack, but the Linux rt_sigaction syscall is prepared to accept a pointer
25    to the sigreturn syscall, instead of inlining it on the stack.
27    This just about halves signal delivery time.  */
29         .text
31 ENTRY(__syscall_rt_sigaction)
32         .frame  sp,0,ra,0
33         ldgp    gp,0(pv)
34 #ifdef PROF
35         .set noat
36         lda     AT, _mcount
37         jsr     AT, (AT), _mcount
38         .set at
39 #endif
40         .prologue 1
42         beq     a1, 0f
43         ldl     t0, 8(a1)                       # sa_flags
45         /* The unwinder will subtract one from the return address when
46            attempting to find the call instruction that led us here.
47            Since we didn't get here via a normal call, if we do nothing
48            we would pick up the wrong symbol and the wrong FDE.  Account
49            for this by adding a nop to the start of the function and 
50            then skipping it here by adding 4.  */
51         ldah    a4, __syscall_sigreturn+4(gp)           !gprelhigh
52         ldah    t1, __syscall_rt_sigreturn+4(gp)        !gprelhigh
53         lda     a4, __syscall_sigreturn+4(a4)           !gprellow
54         lda     t1, __syscall_rt_sigreturn+4(t1)        !gprellow
55         and     t0, 0x40, t0                            # SA_SIGINFO
56         cmovne  t0, t1, a4
58 0:      ldi     v0, __NR_rt_sigaction
59         callsys
60         bne     a3, SYSCALL_ERROR_LABEL
61         ret
63 PSEUDO_END(__syscall_rt_sigaction)
65 /* To enable unwinding through the signal frame without special hackery
66    elsewhere, describe the entire struct sigcontext with unwind info.
68    In order to minimize the size of the encoding, we set the CFA to the
69    end of the sigcontext, which makes all of the registers have small
70    negative offsets from that.  */
72         .macro SIGCONTEXT_REGS_I base, from=0
73         cfi_offset (\from, \base + (4 + \from) * 8)
74         .if     30-\from
75         SIGCONTEXT_REGS_I \base, "(\from+1)"
76         .endif
77         .endm
79         .macro SIGCONTEXT_REGS_F base, from=32
80         cfi_offset (\from, \base + (4 + 1 + \from) * 8)
81         .if     62-\from
82         SIGCONTEXT_REGS_F \base, "(\from+1)"
83         .endif
84         .endm
86         .macro SIGCONTEXT_REGS base
87         SIGCONTEXT_REGS_I \base
88         SIGCONTEXT_REGS_F \base
89         cfi_offset (63, \base + (4 + 32 + 1 + 32) * 8)
90         cfi_offset (64, \base + 2 * 8)
91         .endm
93         .align  4
94         nop
95         nop
96         nop
98         cfi_startproc
99         cfi_return_column (64)
100         SIGCONTEXT_REGS -648
102         cfi_def_cfa_offset (648)
103 __syscall_sigreturn:
104         nop
105         mov     sp, a0
106         ldi     v0, __NR_sigreturn
107         callsys
108         .size   __syscall_sigreturn, .-__syscall_sigreturn
109         .type   __syscall_sigreturn, @function
111         cfi_def_cfa_offset (176 + 648)
112 __syscall_rt_sigreturn:
113         nop
114         mov     sp,a0
115         ldi     v0,__NR_rt_sigreturn
116         callsys
117         .size   __syscall_rt_sigreturn, .-__syscall_rt_sigreturn
118         .type   __syscall_rt_sigreturn, @function
120         cfi_endproc