xref: /titanic_50/usr/src/head/signal.h (revision 6aa4fc89ec1cf2cdf7d7c3b9ec059802ac9abe65)
1 /*
2  * CDDL HEADER START
3  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 /*
26  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
27  *
28  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
29  * Use is subject to license terms.
30  */
31 
32 #ifndef _SIGNAL_H
33 #define	_SIGNAL_H
34 
35 #include <sys/feature_tests.h>
36 
37 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
38 	defined(__XOPEN_OR_POSIX)
39 #include <sys/types.h>	/* need pid_t/uid_t/size_t/clock_t/caddr_t/pthread_t */
40 #endif
41 
42 #include <iso/signal_iso.h>
43 #include <sys/signal.h>
44 
45 /*
46  * Allow global visibility for symbols defined in
47  * C++ "std" namespace in <iso/signal_iso.h>.
48  */
49 #if __cplusplus >= 199711L
50 using std::sig_atomic_t;
51 using std::signal;
52 using std::raise;
53 #endif
54 
55 #ifdef	__cplusplus
56 extern "C" {
57 #endif
58 
59 
60 extern const char	**_sys_siglistp;	/* signal descriptions */
61 extern const int	_sys_siglistn;		/* # of signal descriptions */
62 
63 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
64 #define	_sys_siglist	_sys_siglistp
65 #define	_sys_nsig	_sys_siglistn
66 #endif
67 
68 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
69 	defined(__XOPEN_OR_POSIX)
70 extern int kill(pid_t, int);
71 extern int sigaction(int, const struct sigaction *_RESTRICT_KYWD,
72 	struct sigaction *_RESTRICT_KYWD);
73 #ifndef	_KERNEL
74 extern int sigaddset(sigset_t *, int);
75 extern int sigdelset(sigset_t *, int);
76 extern int sigemptyset(sigset_t *);
77 extern int sigfillset(sigset_t *);
78 extern int sigismember(const sigset_t *, int);
79 #endif
80 extern int sigpending(sigset_t *);
81 extern int sigprocmask(int, const sigset_t *_RESTRICT_KYWD,
82 	sigset_t *_RESTRICT_KYWD);
83 extern int sigsuspend(const sigset_t *);
84 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC)... */
85 
86 #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
87 	!defined(__XOPEN_OR_POSIX))
88 #include <sys/procset.h>
89 extern int gsignal(int);
90 extern int (*ssignal(int, int (*)(int)))(int);
91 extern int sigsend(idtype_t, id_t, int);
92 extern int sigsendset(const procset_t *, int);
93 extern int sig2str(int, char *);
94 extern int str2sig(const char *, int *);
95 #define	SIG2STR_MAX	32
96 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC)... */
97 
98 #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
99 	!defined(__XOPEN_OR_POSIX)) || defined(_XPG4_2)
100 extern void (*bsd_signal(int, void (*)(int)))(int);
101 extern int killpg(pid_t, int);
102 extern int siginterrupt(int, int);
103 extern int sigaltstack(const stack_t *_RESTRICT_KYWD, stack_t *_RESTRICT_KYWD);
104 extern int sighold(int);
105 extern int sigignore(int);
106 extern int sigpause(int);
107 extern int sigrelse(int);
108 extern void (*sigset(int, void (*)(int)))(int);
109 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && ... */
110 
111 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
112 #if defined(__EXTENSIONS__) || \
113 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
114 	(defined(_XPG4_2) && !defined(_XPG6))
115 extern int sigstack(struct sigstack *, struct sigstack *);
116 #endif
117 
118 #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
119 	!defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE > 2)
120 #include <sys/siginfo.h>
121 #include <time.h>
122 extern int pthread_kill(pthread_t, int);
123 extern int pthread_sigmask(int, const sigset_t *_RESTRICT_KYWD,
124 	sigset_t *_RESTRICT_KYWD);
125 extern int sigwaitinfo(const sigset_t *_RESTRICT_KYWD,
126 	siginfo_t *_RESTRICT_KYWD);
127 extern int sigtimedwait(const sigset_t *_RESTRICT_KYWD,
128 	siginfo_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD);
129 extern int sigqueue(pid_t, int, const union sigval);
130 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && */
131 
132 /*
133  * sigwait() prototype is defined here.
134  */
135 
136 #if	defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
137 	!defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
138 	defined(_POSIX_PTHREAD_SEMANTICS)
139 
140 #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
141 
142 #ifdef __PRAGMA_REDEFINE_EXTNAME
143 #pragma redefine_extname sigwait __posix_sigwait
144 extern int sigwait(const sigset_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
145 #else  /* __PRAGMA_REDEFINE_EXTNAME */
146 
147 extern int __posix_sigwait(const sigset_t *_RESTRICT_KYWD,
148     int *_RESTRICT_KYWD);
149 
150 #ifdef	__lint
151 #define	sigwait __posix_sigwait
152 #else	/* !__lint */
153 
154 static int
155 sigwait(const sigset_t *_RESTRICT_KYWD __setp, int *_RESTRICT_KYWD __signo)
156 {
157 	return (__posix_sigwait(__setp, __signo));
158 }
159 
160 #endif /* !__lint */
161 #endif /* __PRAGMA_REDEFINE_EXTNAME */
162 
163 #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
164 
165 extern int sigwait(sigset_t *);
166 
167 #endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
168 
169 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
170 
171 #ifdef	__cplusplus
172 }
173 #endif
174 
175 #endif	/* _SIGNAL_H */
176