summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/common/sigprocmask.c
blob: 7a18648e86cb373066183bae099129850cbeaaa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* vi: set sw=4 ts=4: */
/*
 * sigprocmask() for uClibc
 *
 * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
 *
 * GNU Library General Public License (LGPL) version 2 or later.
 */

#include "syscalls.h"
#include <signal.h>

#undef sigprocmask

#ifdef __NR_rt_sigprocmask

#define __NR___rt_sigprocmask __NR_rt_sigprocmask
static inline
_syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
		  sigset_t *, oldset, size_t, size);

int attribute_hidden __sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
{
	if (set &&
#if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
		(((unsigned int) how) > 2)
#else
#warning "compile time assumption violated.. slow path..."
		((how != SIG_BLOCK) && (how != SIG_UNBLOCK)
		 && (how != SIG_SETMASK))
#endif
		) {
		__set_errno(EINVAL);
		return -1;
	}
	return __rt_sigprocmask(how, set, oldset, _NSIG / 8);
}


#else

#define __NR___syscall_sigprocmask __NR_sigprocmask
static inline
_syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
		  sigset_t *, oldset);

int attribute_hidden __sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
{
	if (set &&
#if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
		(((unsigned int) how) > 2)
#else
#warning "compile time assumption violated.. slow path..."
		((how != SIG_BLOCK) && (how != SIG_UNBLOCK)
		 && (how != SIG_SETMASK))
#endif
		) {
		__set_errno(EINVAL);
		return -1;
	}
	return (__syscall_sigprocmask(how, set, oldset));
}
#endif

strong_alias(__sigprocmask,sigprocmask)