signal.h revision 1.11
1/*	$OpenBSD: signal.h,v 1.11 2007/03/17 21:38:14 espie Exp $	*/
2/*	$NetBSD: signal.h,v 1.8 1996/02/29 00:04:57 jtc Exp $	*/
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.
16 * 3. Neither the name of the University nor the names of its contributors
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
38#include <sys/cdefs.h>
39#include <sys/signal.h>
40
41#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
42#include <sys/types.h>
43#endif
44
45#if __BSD_VISIBLE
46extern __const char *__const sys_signame[_NSIG];
47extern __const char *__const sys_siglist[_NSIG];
48#endif
49
50__BEGIN_DECLS
51int	raise(int);
52#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
53void	(*bsd_signal(int, void (*)(int)))(int);
54int	kill(pid_t, int);
55int	sigaction(int, const struct sigaction *, struct sigaction *);
56int	sigaddset(sigset_t *, int);
57int	sigdelset(sigset_t *, int);
58int	sigemptyset(sigset_t *);
59int	sigfillset(sigset_t *);
60int	sigismember(const sigset_t *, int);
61int	sigpending(sigset_t *);
62int	sigprocmask(int, const sigset_t *, sigset_t *);
63int	sigsuspend(const sigset_t *);
64
65#if defined(__GNUC__)
66#  if  defined(__GNUC_STDC_INLINE__)
67#define __SIGNAL_INLINE	extern __inline __attribute((__gnu_inline__))
68#  else
69#define __SIGNAL_INLINE	extern __inline
70#  endif
71__SIGNAL_INLINE int sigaddset(sigset_t *set, int signo) {
72	int *__errno(void);
73
74	if (signo <= 0 || signo >= _NSIG) {
75		*__errno() = 22;		/* EINVAL */
76		return -1;
77	}
78	*set |= (1 << ((signo)-1));		/* sigmask(signo) */
79	return (0);
80}
81
82__SIGNAL_INLINE int sigdelset(sigset_t *set, int signo) {
83	int *__errno(void);
84
85	if (signo <= 0 || signo >= _NSIG) {
86		*__errno() = 22;		/* EINVAL */
87		return -1;
88	}
89	*set &= ~(1 << ((signo)-1));		/* sigmask(signo) */
90	return (0);
91}
92
93__SIGNAL_INLINE int sigismember(const sigset_t *set, int signo) {
94	int *__errno(void);
95
96	if (signo <= 0 || signo >= _NSIG) {
97		*__errno() = 22;		/* EINVAL */
98		return -1;
99	}
100	return ((*set & (1 << ((signo)-1))) != 0);
101}
102#endif
103
104/* List definitions after function declarations, or Reiser cpp gets upset. */
105#define	sigemptyset(set)	(*(set) = 0, 0)
106#define	sigfillset(set)		(*(set) = ~(sigset_t)0, 0)
107
108#if __BSD_VISIBLE || __XPG_VISIBLE >= 420
109int	killpg(pid_t, int);
110int	siginterrupt(int, int);
111int	sigpause(int);
112int	sigreturn(struct sigcontext *);
113int	sigstack(const struct sigstack *, struct sigstack *);
114int	sigaltstack(const struct sigaltstack *, struct sigaltstack *);
115#if __BSD_VISIBLE
116void	psignal(unsigned int, const char *);
117int	sigblock(int);
118int	sigsetmask(int);
119int	sigvec(int, struct sigvec *, struct sigvec *);
120#endif
121#if __BSD_VISIBLE ||  __POSIX_VISIBLE >= 199309 || __XPG_VISIBLE >= 500
122int	sigwait(const sigset_t *, int *);
123#endif
124#endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
125#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
126__END_DECLS
127
128#endif	/* !_USER_SIGNAL_H */
129