8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / libc / gen / common / posix_sig.c
blobc2b867c912df05c6e4ce85d1759ab41a532b2a01
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * posix signal package
32 #include <stdio.h>
33 #include <signal.h>
34 #include <errno.h>
36 #define cantmask (sigmask(SIGKILL)|sigmask(SIGSTOP))
40 * sigemptyset - all known signals
42 int
43 sigemptyset(sigset_t *sigp)
45 if (!sigp) {
46 errno = EINVAL;
47 return (-1);
49 *sigp = 0;
50 return (0);
54 * sigfillset - all known signals
56 int
57 sigfillset(sigset_t *sigp)
59 if (!sigp) {
60 errno = EINVAL;
61 return (-1);
63 *sigp = sigmask(NSIG - 1) | (sigmask(NSIG - 1) - 1);
64 return (0);
68 * add the signal to the set
70 int
71 sigaddset(sigset_t *sigp, int signo)
73 if (!sigp || signo <= 0 || signo >= NSIG) {
74 errno = EINVAL;
75 return (-1);
77 *sigp |= sigmask(signo);
78 return (0);
82 * remove the signal from the set
84 int
85 sigdelset(sigset_t *sigp, int signo)
87 if (!sigp || signo <= 0 || signo >= NSIG) {
88 errno = EINVAL;
89 return (-1);
91 *sigp &= ~sigmask(signo);
92 return (0);
96 * return true if the signal is in the set (return is 0 or 1)
98 int
99 sigismember(sigset_t *sigp, int signo)
101 if (!sigp || signo <= 0 || signo >= NSIG) {
102 errno = EINVAL;
103 return (-1);
105 return ((*sigp & sigmask(signo)) != 0);