drm/linux: Restore wait_event*() functionality
[dragonfly.git] / contrib / opie / libmissing / sigprocmask.c
1 /* sigprocmask.c: A replacement for the sigprocmask() function
2
3 %%% portions-copyright-cmetz
4 Portions of this software are Copyright 1996 by Craig Metz, All Rights
5 Reserved. The Inner Net License Version 2 applies to these portions of
6 the software.
7 You should have received a copy of the license with this software. If
8 you didn't get a copy, you may request one from <license@inner.net>.
9
10 Portions of this software are Copyright 1995 by Randall Atkinson and Dan
11 McDonald, All Rights Reserved. All Rights under this copyright are assigned
12 to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
13 License Agreement applies to this software.
14
15         History:
16
17         Created by cmetz for OPIE 2.2 from popen.c. Use FUNCTION
18                declaration et al. Include opie.h.
19 */
20
21 #include "opie_cfg.h"
22
23 #include <sys/types.h>
24 #if HAVE_SIGNAL_H
25 #include <signal.h>
26 #endif /* HAVE_SIGNAL_H */
27 #if HAVE_SYS_SIGNAL_H
28 #include <sys/signal.h>
29 #endif /* HAVE_SYS_SIGNAL_H */
30
31 #if !HAVE_SIGBLOCK || !HAVE_SIGSETMASK
32 Without sigblock and sigsetmask, we can't build a replacement sigprocmask.
33 #endif /* !HAVE_SIGBLOCK || !HAVE_SIGSETMASK */
34
35 #include "opie.h"
36
37 #ifndef sigset_t
38 #define sigset_t int
39 #endif /* sigset_t */
40
41 int sigprocmask FUNCTION((how, set, oset), int how AND sigset_t *set AND sigset_t *oset)
42 {
43         int old, new;
44
45         if (set && (set != (sigset_t *)SIG_IGN) && (set != (sigset_t *)SIG_ERR))
46                 new = *set;
47         else
48                 new = 0;
49
50         switch(how) {
51                 case SIG_BLOCK:
52                         old = sigblock(new);
53                         if (oset && (oset != (sigset_t *)SIG_IGN) && (oset != (sigset_t *)SIG_ERR))
54                                 *oset = old;
55                         return 0;
56
57                 case SIG_SETMASK:
58                         old = sigsetmask(new);
59                         if (oset && (oset != (sigset_t *)SIG_IGN) && (oset != (sigset_t *)SIG_ERR))
60                                 *oset = old;
61                         return 0;
62
63                 case SIG_UNBLOCK:
64                         /* not implemented */
65                 default:
66                         return 0;
67         }
68 }