1*5688dfcfSmatt /* $NetBSD: compat_sigsetops.c,v 1.3 2012/03/20 17:05:59 matt Exp $ */
25b84b398Schristos
35b84b398Schristos /*-
45b84b398Schristos * Copyright (c) 1989, 1993
55b84b398Schristos * The Regents of the University of California. All rights reserved.
65b84b398Schristos *
75b84b398Schristos * Redistribution and use in source and binary forms, with or without
85b84b398Schristos * modification, are permitted provided that the following conditions
95b84b398Schristos * are met:
105b84b398Schristos * 1. Redistributions of source code must retain the above copyright
115b84b398Schristos * notice, this list of conditions and the following disclaimer.
125b84b398Schristos * 2. Redistributions in binary form must reproduce the above copyright
135b84b398Schristos * notice, this list of conditions and the following disclaimer in the
145b84b398Schristos * documentation and/or other materials provided with the distribution.
155b84b398Schristos * 3. Neither the name of the University nor the names of its contributors
165b84b398Schristos * may be used to endorse or promote products derived from this software
175b84b398Schristos * without specific prior written permission.
185b84b398Schristos *
195b84b398Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
205b84b398Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
215b84b398Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
225b84b398Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
235b84b398Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
245b84b398Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
255b84b398Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
265b84b398Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
275b84b398Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
285b84b398Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
295b84b398Schristos * SUCH DAMAGE.
305b84b398Schristos *
315b84b398Schristos * @(#)sigsetops.c 8.1 (Berkeley) 6/4/93
325b84b398Schristos */
335b84b398Schristos
345b84b398Schristos #include <sys/cdefs.h>
355b84b398Schristos #if defined(LIBC_SCCS) && !defined(lint)
365b84b398Schristos #if 0
375b84b398Schristos static char sccsid[] = "@(#)sigsetops.c 8.1 (Berkeley) 6/4/93";
385b84b398Schristos #else
39*5688dfcfSmatt __RCSID("$NetBSD: compat_sigsetops.c,v 1.3 2012/03/20 17:05:59 matt Exp $");
405b84b398Schristos #endif
415b84b398Schristos #endif /* LIBC_SCCS and not lint */
425b84b398Schristos
435b84b398Schristos #define __LIBC12_SOURCE__
445b84b398Schristos
455b84b398Schristos #include <errno.h>
46461a86f9Schristos #include <sys/time.h>
47461a86f9Schristos #include <compat/sys/time.h>
485b84b398Schristos #include <signal.h>
495b84b398Schristos #include <compat/include/signal.h>
505b84b398Schristos
515b84b398Schristos #undef sigemptyset
525b84b398Schristos #undef sigfillset
535b84b398Schristos #undef sigaddset
545b84b398Schristos #undef sigdelset
555b84b398Schristos #undef sigismember
565b84b398Schristos
575b84b398Schristos __warn_references(sigaddset,
585b84b398Schristos "warning: reference to compatibility sigaddset(); include <signal.h> for correct reference")
595b84b398Schristos __warn_references(sigdelset,
605b84b398Schristos "warning: reference to compatibility sigdelset(); include <signal.h> for correct reference")
615b84b398Schristos __warn_references(sigemptyset,
625b84b398Schristos "warning: reference to compatibility sigemptyset(); include <signal.h> for correct reference")
635b84b398Schristos __warn_references(sigfillset,
645b84b398Schristos "warning: reference to compatibility sigfillset(); include <signal.h> for correct reference")
655b84b398Schristos __warn_references(sigismember,
665b84b398Schristos "warning: reference to compatibility sigismember(); include <signal.h> for correct reference")
675b84b398Schristos
685b84b398Schristos int
sigemptyset(sigset13_t * set)69*5688dfcfSmatt sigemptyset(sigset13_t *set)
705b84b398Schristos {
715b84b398Schristos *set = 0;
725b84b398Schristos return (0);
735b84b398Schristos }
745b84b398Schristos
755b84b398Schristos int
sigfillset(sigset13_t * set)76*5688dfcfSmatt sigfillset(sigset13_t *set)
775b84b398Schristos {
785b84b398Schristos *set = ~(sigset13_t)0;
795b84b398Schristos return (0);
805b84b398Schristos }
815b84b398Schristos
825b84b398Schristos int
sigaddset(sigset13_t * set,int signo)83*5688dfcfSmatt sigaddset(sigset13_t *set, int signo)
845b84b398Schristos {
855b84b398Schristos if (signo <= 0 || signo >= NSIG13) {
865b84b398Schristos errno = EINVAL;
875b84b398Schristos return -1;
885b84b398Schristos }
895b84b398Schristos *set |= __sigmask13(signo);
905b84b398Schristos return (0);
915b84b398Schristos }
925b84b398Schristos
935b84b398Schristos int
sigdelset(sigset13_t * set,int signo)94*5688dfcfSmatt sigdelset(sigset13_t *set, int signo)
955b84b398Schristos {
965b84b398Schristos if (signo <= 0 || signo >= NSIG13) {
975b84b398Schristos errno = EINVAL;
985b84b398Schristos return -1;
995b84b398Schristos }
1005b84b398Schristos *set &= ~__sigmask13(signo);
1015b84b398Schristos return (0);
1025b84b398Schristos }
1035b84b398Schristos
1045b84b398Schristos int
sigismember(const sigset13_t * set,int signo)105*5688dfcfSmatt sigismember(const sigset13_t *set, int signo)
1065b84b398Schristos {
1075b84b398Schristos if (signo <= 0 || signo >= NSIG13) {
1085b84b398Schristos errno = EINVAL;
1095b84b398Schristos return -1;
1105b84b398Schristos }
1115b84b398Schristos return ((*set & __sigmask13(signo)) != 0);
1125b84b398Schristos }
113