Annotation of src/include/signal.h, Revision 1.17
1.17 ! kettenis 1: /* $OpenBSD: signal.h,v 1.16 2011/11/22 21:13:30 guenther Exp $ */
1.2 niklas 2: /* $NetBSD: signal.h,v 1.8 1996/02/29 00:04:57 jtc Exp $ */
1.1 deraadt 3:
4: /*-
5: * Copyright (c) 1991, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
1.7 millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: * may be used to endorse or promote products derived from this software
18: * without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: *
32: * @(#)signal.h 8.3 (Berkeley) 3/30/94
33: */
34:
35: #ifndef _USER_SIGNAL_H
36: #define _USER_SIGNAL_H
37:
1.9 millert 38: #include <sys/cdefs.h>
1.1 deraadt 39: #include <sys/signal.h>
40:
1.9 millert 41: #if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
1.1 deraadt 42: #include <sys/types.h>
43: #endif
44:
1.12 kettenis 45: __BEGIN_DECLS
1.9 millert 46: #if __BSD_VISIBLE
1.1 deraadt 47: extern __const char *__const sys_signame[_NSIG];
48: extern __const char *__const sys_siglist[_NSIG];
49: #endif
50:
1.5 millert 51: int raise(int);
1.9 millert 52: #if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
1.8 millert 53: void (*bsd_signal(int, void (*)(int)))(int);
1.5 millert 54: int kill(pid_t, int);
55: int sigaction(int, const struct sigaction *, struct sigaction *);
56: int sigaddset(sigset_t *, int);
57: int sigdelset(sigset_t *, int);
58: int sigemptyset(sigset_t *);
59: int sigfillset(sigset_t *);
60: int sigismember(const sigset_t *, int);
61: int sigpending(sigset_t *);
62: int sigprocmask(int, const sigset_t *, sigset_t *);
1.17 ! kettenis 63: #if __POSIX_VISIBLE >= 199506
! 64: int pthread_sigmask(int, const sigset_t *, sigset_t *);
! 65: #endif
1.5 millert 66: int sigsuspend(const sigset_t *);
1.1 deraadt 67:
1.14 guenther 68: #if !defined(_ANSI_LIBRARY) && !defined(lint)
69:
70: __only_inline int sigaddset(sigset_t *set, int signo) {
1.10 millert 71: int *__errno(void);
1.1 deraadt 72:
73: if (signo <= 0 || signo >= _NSIG) {
1.10 millert 74: *__errno() = 22; /* EINVAL */
1.1 deraadt 75: return -1;
76: }
1.15 guenther 77: *set |= (1U << ((signo)-1)); /* sigmask(signo) */
1.1 deraadt 78: return (0);
79: }
80:
1.14 guenther 81: __only_inline int sigdelset(sigset_t *set, int signo) {
1.10 millert 82: int *__errno(void);
1.1 deraadt 83:
84: if (signo <= 0 || signo >= _NSIG) {
1.10 millert 85: *__errno() = 22; /* EINVAL */
1.1 deraadt 86: return -1;
87: }
1.15 guenther 88: *set &= ~(1U << ((signo)-1)); /* sigmask(signo) */
1.1 deraadt 89: return (0);
90: }
91:
1.14 guenther 92: __only_inline int sigismember(const sigset_t *set, int signo) {
1.10 millert 93: int *__errno(void);
1.1 deraadt 94:
95: if (signo <= 0 || signo >= _NSIG) {
1.10 millert 96: *__errno() = 22; /* EINVAL */
1.1 deraadt 97: return -1;
98: }
1.15 guenther 99: return ((*set & (1U << ((signo)-1))) != 0);
1.1 deraadt 100: }
1.14 guenther 101: #endif /* !_ANSI_LIBRARY && !lint */
1.1 deraadt 102:
103: /* List definitions after function declarations, or Reiser cpp gets upset. */
104: #define sigemptyset(set) (*(set) = 0, 0)
105: #define sigfillset(set) (*(set) = ~(sigset_t)0, 0)
106:
1.9 millert 107: #if __BSD_VISIBLE || __XPG_VISIBLE >= 420
1.5 millert 108: int killpg(pid_t, int);
109: int siginterrupt(int, int);
110: int sigpause(int);
111: int sigaltstack(const struct sigaltstack *, struct sigaltstack *);
1.9 millert 112: #if __BSD_VISIBLE
113: int sigblock(int);
1.16 guenther 114: int sigreturn(struct sigcontext *);
1.9 millert 115: int sigsetmask(int);
1.5 millert 116: int sigvec(int, struct sigvec *, struct sigvec *);
1.9 millert 117: #endif
1.16 guenther 118: #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
1.9 millert 119: #if __BSD_VISIBLE || __POSIX_VISIBLE >= 199309 || __XPG_VISIBLE >= 500
1.5 millert 120: int sigwait(const sigset_t *, int *);
1.9 millert 121: #endif
1.16 guenther 122: #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
123: void psignal(unsigned int, const char *);
124: #endif
1.9 millert 125: #endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
1.1 deraadt 126: __END_DECLS
127:
128: #endif /* !_USER_SIGNAL_H */