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
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 <features.h>
20#include <sys/syscall.h>
21#include <sys/regdef.h>
22
23/* On Alpha we desparately want to avoid having to issue an imb.  Ordinarily
24   the kernel would have to issue one after setting up the signal return
25   stack, but the Linux rt_sigaction syscall is prepared to accept a pointer
26   to the sigreturn syscall, instead of inlining it on the stack.
27
28   This just about halves signal delivery time.  */
29
30	.text
31
32.globl __syscall_rt_sigaction
33#ifndef __UCLIBC_HAS_THREADS_NATIVE__
34.hidden __syscall_rt_sigaction
35#endif
36.align 4
37.ent __syscall_rt_sigaction, 0
38__syscall_rt_sigaction:
39	.frame	sp,0,ra,0
40	ldgp	gp,0(pv)
41	.prologue 1
42
43	beq	a1, 0f
44	ldl	t0, 8(a1)			# sa_flags
45
46	/* The unwinder will subtract one from the return address when
47	   attempting to find the call instruction that led us here.
48	   Since we didn't get here via a normal call, if we do nothing
49	   we would pick up the wrong symbol and the wrong FDE.  Account
50	   for this by adding a nop to the start of the function and
51	   then skipping it here by adding 4.  */
52	ldah	a4, __syscall_sigreturn+4(gp)		!gprelhigh
53	ldah	t1, __syscall_rt_sigreturn+4(gp)	!gprelhigh
54	lda	a4, __syscall_sigreturn+4(a4)		!gprellow
55	lda	t1, __syscall_rt_sigreturn+4(t1)	!gprellow
56	and	t0, 0x40, t0				# SA_SIGINFO
57	cmovne	t0, t1, a4
58
590:	ldi	v0, __NR_rt_sigaction
60	callsys
61	bne	a3, $error
62	ret
63
64$error:
65	jmp	zero,__syscall_error
66
67.end __syscall_rt_sigaction
68
69__syscall_sigreturn:
70	nop
71	mov	sp, a0
72	ldi	v0, __NR_sigreturn
73	callsys
74	.size	__syscall_sigreturn, .-__syscall_sigreturn
75	.type	__syscall_sigreturn, @function
76
77__syscall_rt_sigreturn:
78	nop
79	mov	sp,a0
80	ldi	v0,__NR_rt_sigreturn
81	callsys
82	.size	__syscall_rt_sigreturn, .-__syscall_rt_sigreturn
83	.type	__syscall_rt_sigreturn, @function
84