OSDN Git Service

Remove the nonexistant __sigaction
[uclinux-h8/uClibc.git] / include / signal.h
1 /* Copyright (C) 1991-1999, 2000 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public
15    License along with the GNU C Library; see the file COPYING.LIB.  If not,
16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17    Boston, MA 02111-1307, USA.  */
18
19 /*
20  *      ISO C Standard: 4.7 SIGNAL HANDLING <signal.h>
21  */
22
23 #ifndef _SIGNAL_H
24
25 #if !defined __need_sig_atomic_t && !defined __need_sigset_t
26 # define _SIGNAL_H
27 #endif
28
29 #include <features.h>
30 #include <sys/types.h>
31
32 __BEGIN_DECLS
33
34 //#include <asm/signal.h>
35 #include <bits/sigset.h>                /* __sigset_t, __sig_atomic_t.  */
36
37 /* An integral type that can be modified atomically, without the
38    possibility of a signal arriving in the middle of the operation.  */
39 typedef __sig_atomic_t sig_atomic_t;
40
41 typedef __sigset_t sigset_t;
42
43 #ifdef _SIGNAL_H
44
45 //#include <bits/types.h>
46 #include <bits/signum.h>
47
48 #ifdef __USE_XOPEN
49 # ifndef pid_t
50 typedef __pid_t pid_t;
51 #  define pid_t pid_t
52 # endif
53 # ifndef uid_t
54 typedef __uid_t uid_t;
55 #  define uid_t uid_t
56 # endif
57 #endif  /* Unix98 */
58
59
60 /* Type of a signal handler.  */
61 typedef void (*__sighandler_t) __P ((int));
62
63 /* The X/Open definition of `signal' specifies the SVID semantic.  Use
64    the additional function `sysv_signal' when X/Open compatibility is
65    requested.  */
66 extern __sighandler_t __sysv_signal __P ((int __sig,
67                                           __sighandler_t __handler));
68 #ifdef __USE_GNU
69 extern __sighandler_t sysv_signal __P ((int __sig, __sighandler_t __handler));
70 #endif
71
72 /* Set the handler for the signal SIG to HANDLER, returning the old
73    handler, or SIG_ERR on error.
74    By default `signal' has the BSD semantic.  */
75 #ifdef __USE_BSD
76 extern __sighandler_t signal __P ((int __sig, __sighandler_t __handler));
77 #else
78 /* Make sure the used `signal' implementation is the SVID version. */
79 # ifdef __REDIRECT
80 extern __sighandler_t __REDIRECT (signal,
81                                   __P ((int __sig, __sighandler_t __handler)),
82                                   __sysv_signal);
83 # else
84 #  define signal __sysv_signal
85 # endif
86 #endif
87
88 #ifdef __USE_XOPEN
89 /* The X/Open definition of `signal' conflicts with the BSD version.
90    So they defined another function `bsd_signal'.  */
91 extern __sighandler_t bsd_signal __P ((int __sig, __sighandler_t __handler));
92 #endif
93
94 /* Send signal SIG to process number PID.  If PID is zero,
95    send SIG to all processes in the current process's process group.
96    If PID is < -1, send SIG to all processes in process group - PID.  */
97 #ifdef __USE_POSIX
98 extern int kill __P ((__pid_t __pid, int __sig));
99 #endif /* Use POSIX.  */
100
101 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
102 /* Send SIG to all processes in process group PGRP.
103    If PGRP is zero, send SIG to all processes in
104    the current process's process group.  */
105 extern int killpg __P ((__pid_t __pgrp, int __sig));
106 #endif /* Use BSD || X/Open Unix.  */
107
108 /* Raise signal SIG, i.e., send SIG to yourself.  */
109 extern int raise __P ((int __sig));
110
111 #ifdef __USE_SVID
112 /* SVID names for the same things.  */
113 extern __sighandler_t ssignal __P ((int __sig, __sighandler_t __handler));
114 extern int gsignal __P ((int __sig));
115 #endif /* Use SVID.  */
116
117 #ifdef __USE_MISC
118 /* Print a message describing the meaning of the given signal number.  */
119 extern void psignal __P ((int __sig, __const char *__s));
120 #endif /* Use misc.  */
121
122
123 /* The `sigpause' function has two different interfaces.  The original
124    BSD definition defines the argument as a mask of the signal, while
125    the more modern interface in X/Open defines it as the signal
126    number.  We go with the BSD version unless the user explicitly
127    selects the X/Open version.  */
128 extern int __sigpause __P ((int __sig_or_mask, int __is_sig));
129
130 #ifdef __USE_BSD
131 /* Set the mask of blocked signals to MASK,
132    wait for a signal to arrive, and then restore the mask.  */
133 extern int sigpause __P ((int __mask));
134 # define sigpause(mask) __sigpause ((mask), 0)
135 #else
136 # ifdef __USE_XOPEN
137 /* Remove a signal from the signal mask and suspend the process.  */
138 #  define sigpause(sig) __sigpause ((sig), 1)
139 # endif
140 #endif
141
142
143 #ifdef __USE_BSD
144 /* None of the following functions should be used anymore.  They are here
145    only for compatibility.  A single word (`int') is not guaranteed to be
146    enough to hold a complete signal mask and therefore these functions
147    simply do not work in many situations.  Use `sigprocmask' instead.  */
148
149 /* Compute mask for signal SIG.  */
150 # define sigmask(sig)   __sigmask(sig)
151
152 /* Block signals in MASK, returning the old mask.  */
153 extern int sigblock __P ((int __mask));
154
155 /* Set the mask of blocked signals to MASK, returning the old mask.  */
156 extern int sigsetmask __P ((int __mask));
157
158 /* Return currently selected signal mask.  */
159 extern int siggetmask __P ((void));
160 #endif /* Use BSD.  */
161
162
163 #ifdef __USE_MISC
164 # define NSIG   _NSIG
165 #endif
166
167 #ifdef __USE_GNU
168 typedef __sighandler_t sighandler_t;
169 #endif
170
171 /* 4.4 BSD uses the name `sig_t' for this.  */
172 #ifdef __USE_BSD
173 typedef __sighandler_t sig_t;
174 #endif
175
176 #ifdef __USE_POSIX
177
178 # ifdef __USE_POSIX199309
179 /* We need `struct timespec' later on.  */
180 #  define __need_timespec
181 #  include <time.h>
182
183 /* Get the `siginfo_t' type plus the needed symbols.  */
184 #  include <bits/siginfo.h>
185 # endif
186
187 /* Clear all signals from SET.  */
188 extern int sigemptyset __P ((sigset_t *__set));
189
190 /* Set all signals in SET.  */
191 extern int sigfillset __P ((sigset_t *__set));
192
193 /* Add SIGNO to SET.  */
194 extern int sigaddset __P ((sigset_t *__set, int __signo));
195
196 /* Remove SIGNO from SET.  */
197 extern int sigdelset __P ((sigset_t *__set, int __signo));
198
199 /* Return 1 if SIGNO is in SET, 0 if not.  */
200 extern int sigismember __P ((__const sigset_t *__set, int __signo));
201
202 # ifdef __USE_GNU
203 /* Return non-empty value is SET is not empty.  */
204 extern int sigisemptyset __P ((__const sigset_t *__set));
205
206 /* Build new signal set by combining the two inputs set using logical AND.  */
207 extern int sigandset __P ((sigset_t *__set, __const sigset_t *__left,
208                            __const sigset_t *__right));
209
210 /* Build new signal set by combining the two inputs set using logical OR.  */
211 extern int sigorset __P ((sigset_t *__set, __const sigset_t *__left,
212                           __const sigset_t *__right));
213 # endif /* GNU */
214
215 /* Get the system-specific definitions of `struct sigaction'
216    and the `SA_*' and `SIG_*'. constants.  */
217 # include <bits/sigaction.h>
218
219 /* Get and/or change the set of blocked signals.  */
220 extern int sigprocmask __P ((int __how,
221                              __const sigset_t *__set, sigset_t *__oset));
222
223 /* Change the set of blocked signals to SET,
224    wait until a signal arrives, and restore the set of blocked signals.  */
225 extern int sigsuspend __P ((__const sigset_t *__set));
226
227 /* Get and/or set the action for signal SIG.  */
228 extern int sigaction __P ((int __sig, __const struct sigaction *__act,
229                            struct sigaction *__oact));
230
231 /* Put in SET all signals that are blocked and waiting to be delivered.  */
232 extern int sigpending __P ((sigset_t *__set));
233
234
235 /* Select any of pending signals from SET or wait for any to arrive.  */
236 extern int sigwait __P ((__const sigset_t *__set, int *__sig));
237
238 # ifdef __USE_POSIX199309
239 /* Select any of pending signals from SET and place information in INFO.  */
240 extern int sigwaitinfo __P ((__const sigset_t *__set, siginfo_t *__info));
241
242 /* Select any of pending signals from SET and place information in INFO.
243    Wait the imte specified by TIMEOUT if no signal is pending.  */
244 extern int sigtimedwait __P ((__const sigset_t *__set, siginfo_t *__info,
245                               __const struct timespec *__timeout));
246
247 /* Send signal SIG to the process PID.  Associate data in VAL with the
248    signal.  */
249 extern int sigqueue __P ((__pid_t __pid, int __sig,
250                           __const union sigval __val));
251 # endif /* Use POSIX 199306.  */
252
253 #endif /* Use POSIX.  */
254
255 #ifdef __USE_BSD
256
257 /* Names of the signals.  This variable exists only for compatibility.
258    Use `strsignal' instead (see <string.h>).  */
259 extern __const char *__const _sys_siglist[_NSIG];
260 extern __const char *__const sys_siglist[_NSIG];
261
262 /* Structure passed to `sigvec'.  */
263 struct sigvec
264   {
265     __sighandler_t sv_handler;  /* Signal handler.  */
266     int sv_mask;                /* Mask of signals to be blocked.  */
267
268     int sv_flags;               /* Flags (see below).  */
269 # define sv_onstack     sv_flags /* 4.2 BSD compatibility.  */
270   };
271
272 /* Bits in `sv_flags'.  */
273 # define SV_ONSTACK     (1 << 0)/* Take the signal on the signal stack.  */
274 # define SV_INTERRUPT   (1 << 1)/* Do not restart system calls.  */
275 # define SV_RESETHAND   (1 << 2)/* Reset handler to SIG_DFL on receipt.  */
276
277
278 /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
279    of VEC.  The signals in `sv_mask' will be blocked while the handler runs.
280    If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
281    reset to SIG_DFL before `sv_handler' is entered.  If OVEC is non-NULL,
282    it is filled in with the old information for SIG.  */
283 extern int sigvec __P ((int __sig, __const struct sigvec *__vec,
284                         struct sigvec *__ovec));
285
286
287 /* Get machine-dependent `struct sigcontext' and signal subcodes.  */
288 # include <bits/sigcontext.h>
289
290 /* Restore the state saved in SCP.  */
291 extern int sigreturn __P ((struct sigcontext *__scp));
292
293 #endif /*  use BSD.  */
294
295
296 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
297
298 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
299    (causing them to fail with EINTR); if INTERRUPT is zero, make system
300    calls be restarted after signal SIG.  */
301 extern int siginterrupt __P ((int __sig, int __interrupt));
302
303 # include <bits/sigstack.h>
304 # ifdef __USE_GNU
305 #  include <ucontext.h>
306 # endif
307
308 /* Run signals handlers on the stack specified by SS (if not NULL).
309    If OSS is not NULL, it is filled in with the old signal stack status.
310    This interface is obsolete and on many platform not implemented.  */
311 extern int sigstack __P ((struct sigstack *__ss, struct sigstack *__oss));
312
313 /* Alternate signal handler stack interface.
314    This interface should always be preferred over `sigstack'.  */
315 extern int sigaltstack __P ((__const struct sigaltstack *__ss,
316                              struct sigaltstack *__oss));
317
318 #endif /* use BSD or X/Open Unix.  */
319
320 #ifdef __USE_UNIX98
321 /* Simplified interface for signal management.  */
322
323 /* Add SIG to the calling process' signal mask.  */
324 extern int sighold __P ((int __sig));
325
326 /* Remove SIG from the calling process' signal mask.  */
327 extern int sigrelse __P ((int __sig));
328
329 /* Set the disposition of SIG to SIG_IGN.  */
330 extern int sigignore __P ((int __sig));
331
332 /* Set the disposition of SIG.  */
333 extern __sighandler_t sigset __P ((int __sig, __sighandler_t __disp));
334
335 /* Some of the functions for handling signals in threaded programs must
336    be defined here.  */
337 # include <bits/sigthread.h>
338 #endif /* use Unix98 */
339
340 /* The following functions are used internally in the C library and in
341    other code which need deep insights.  */
342
343 /* Return number of available real-time signal with highest priority.  */
344 extern int __libc_current_sigrtmin __P ((void));
345 /* Return number of available real-time signal with lowest priority.  */
346 extern int __libc_current_sigrtmax __P ((void));
347
348 extern int      __sigprocmask __P ((int __how, __const sigset_t *__set,
349                         sigset_t *__oldset));
350 extern int      sigprocmask __P ((int __how, __const sigset_t *__set,
351                         sigset_t *__oldset));
352 #endif /* signal.h  */
353
354 __END_DECLS
355
356 #endif /* not signal.h */