1/* $OpenBSD: sigprocmask.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */
2
3/*
4 * Copyright (c) 1996 Dale Rahn
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28/* sigprocmask(int how, const sigset_t *set, sigset_t *oset); */
29
30#include "SYS.h"
31
32	.text
33SYSENTRY_HIDDEN(sigprocmask)
34	RETGUARD_SETUP(sigprocmask, %r11)
35	li	%r0, SYS_sigprocmask
36
37	stdu	%r1, -32(%r1)
38	std	%r5, 16(%r1)
39
40	/* check set (new mask value) for null, in which case
41	   fiddle arguments */
42	cmpdi	%r4, 0
43	bne+	.L_load_set
44	addi	%r3, 0, 1	/* how = SIG_BLOCK, new mask already 0 */
45	b .L_do_call
46.L_load_set:
47	lwz	%r4, 0(%r4)	/* get new mask */
48.L_do_call:
49
5099:	sc
51	PINSYSCALL(SYS_sigprocmask, 99b)
52
53	/* didnt work? */
54	cmpwi	%r0, 0
55	beq+	.L_sigprocmask_ok
56	stw	%r0, R13_OFFSET_ERRNO(%r13)
57	li	%r3, -1
58	b	.L_end
59
60.L_sigprocmask_ok:
61	ld	%r5, 16(%r1)
62	cmpdi	%r5, 0
63	beq+	.L_sigprocmask_done
64	stw	%r3, 0(%r5)
65.L_sigprocmask_done:
66	li	%r3, 0
67	addi	%r1, %r1, 32
68.L_end:
69	RETGUARD_CHECK(sigprocmask, %r11)
70	blr
71SYSCALL_END_HIDDEN(sigprocmask)
72