Rev 4921 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* sys/signal.h */ |
2 | |||
3 | #ifndef _SYS_SIGNAL_H |
||
4 | #define _SYS_SIGNAL_H |
||
5 | #ifdef __cplusplus |
||
6 | extern "C" { |
||
7 | #endif |
||
8 | |||
9 | #include "_ansi.h" |
||
6099 | serge | 10 | #include |
4349 | Serge | 11 | #include |
12 | #include |
||
6099 | serge | 13 | #include |
14 | #include |
||
4349 | Serge | 15 | |
16 | /* #ifndef __STRICT_ANSI__*/ |
||
17 | |||
6099 | serge | 18 | #if !defined(_SIGSET_T_DECLARED) |
19 | #define _SIGSET_T_DECLARED |
||
20 | typedef __sigset_t sigset_t; |
||
4921 | Serge | 21 | #endif |
4349 | Serge | 22 | |
23 | #if defined(__rtems__) |
||
24 | |||
25 | #if defined(_POSIX_REALTIME_SIGNALS) |
||
26 | |||
27 | /* sigev_notify values |
||
28 | NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */ |
||
29 | |||
30 | #define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */ |
||
31 | /* when the event of interest occurs. */ |
||
32 | #define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */ |
||
33 | /* value, shall be delivered when the event of */ |
||
34 | /* interest occurs. */ |
||
35 | #define SIGEV_THREAD 3 /* A notification function shall be called to */ |
||
36 | /* perform notification. */ |
||
37 | |||
38 | /* Signal Generation and Delivery, P1003.1b-1993, p. 63 |
||
39 | NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and |
||
40 | sigev_notify_attributes to the sigevent structure. */ |
||
41 | |||
42 | union sigval { |
||
43 | int sival_int; /* Integer signal value */ |
||
44 | void *sival_ptr; /* Pointer signal value */ |
||
45 | }; |
||
46 | |||
47 | struct sigevent { |
||
48 | int sigev_notify; /* Notification type */ |
||
49 | int sigev_signo; /* Signal number */ |
||
50 | union sigval sigev_value; /* Signal value */ |
||
51 | |||
52 | #if defined(_POSIX_THREADS) |
||
53 | void (*sigev_notify_function)( union sigval ); |
||
54 | /* Notification function */ |
||
55 | pthread_attr_t *sigev_notify_attributes; /* Notification Attributes */ |
||
56 | #endif |
||
57 | }; |
||
58 | |||
59 | /* Signal Actions, P1003.1b-1993, p. 64 */ |
||
60 | /* si_code values, p. 66 */ |
||
61 | |||
62 | #define SI_USER 1 /* Sent by a user. kill(), abort(), etc */ |
||
63 | #define SI_QUEUE 2 /* Sent by sigqueue() */ |
||
64 | #define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */ |
||
65 | #define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */ |
||
66 | #define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */ |
||
67 | |||
68 | typedef struct { |
||
69 | int si_signo; /* Signal number */ |
||
70 | int si_code; /* Cause of the signal */ |
||
71 | union sigval si_value; /* Signal value */ |
||
72 | } siginfo_t; |
||
73 | #endif |
||
74 | |||
75 | /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */ |
||
76 | |||
6099 | serge | 77 | #define SA_NOCLDSTOP 0x1 /* Do not generate SIGCHLD when children stop */ |
78 | #define SA_SIGINFO 0x2 /* Invoke the signal catching function with */ |
||
79 | /* three arguments instead of one. */ |
||
80 | #if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 |
||
81 | #define SA_ONSTACK 0x4 /* Signal delivery will be on a separate stack. */ |
||
82 | #endif |
||
4349 | Serge | 83 | |
84 | /* struct sigaction notes from POSIX: |
||
85 | * |
||
86 | * (1) Routines stored in sa_handler should take a single int as |
||
87 | * their argument although the POSIX standard does not require this. |
||
88 | * This is not longer true since at least POSIX.1-2008 |
||
89 | * (2) The fields sa_handler and sa_sigaction may overlap, and a conforming |
||
90 | * application should not use both simultaneously. |
||
91 | */ |
||
92 | |||
93 | typedef void (*_sig_func_ptr)(int); |
||
94 | |||
95 | struct sigaction { |
||
96 | int sa_flags; /* Special flags to affect behavior of signal */ |
||
97 | sigset_t sa_mask; /* Additional set of signals to be blocked */ |
||
98 | /* during execution of signal-catching */ |
||
99 | /* function. */ |
||
100 | union { |
||
101 | _sig_func_ptr _handler; /* SIG_DFL, SIG_IGN, or pointer to a function */ |
||
102 | #if defined(_POSIX_REALTIME_SIGNALS) |
||
103 | void (*_sigaction)( int, siginfo_t *, void * ); |
||
104 | #endif |
||
105 | } _signal_handlers; |
||
106 | }; |
||
107 | |||
108 | #define sa_handler _signal_handlers._handler |
||
109 | #if defined(_POSIX_REALTIME_SIGNALS) |
||
110 | #define sa_sigaction _signal_handlers._sigaction |
||
111 | #endif |
||
112 | |||
113 | #elif defined(__CYGWIN__) |
||
114 | #include |
||
115 | #else |
||
116 | #define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */ |
||
117 | |||
118 | typedef void (*_sig_func_ptr)(int); |
||
119 | |||
120 | struct sigaction |
||
121 | { |
||
122 | _sig_func_ptr sa_handler; |
||
123 | sigset_t sa_mask; |
||
124 | int sa_flags; |
||
125 | }; |
||
126 | #endif /* defined(__rtems__) */ |
||
127 | |||
6099 | serge | 128 | #if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 |
129 | /* |
||
130 | * Minimum and default signal stack constants. Allow for target overrides |
||
131 | * from |
||
132 | */ |
||
133 | #ifndef MINSIGSTKSZ |
||
134 | #define MINSIGSTKSZ 2048 |
||
135 | #endif |
||
136 | #ifndef SIGSTKSZ |
||
137 | #define SIGSTKSZ 8192 |
||
138 | #endif |
||
139 | |||
140 | /* |
||
141 | * Possible values for ss_flags in stack_t below. |
||
142 | */ |
||
143 | #define SS_ONSTACK 0x1 |
||
144 | #define SS_DISABLE 0x2 |
||
145 | |||
146 | #endif |
||
147 | |||
148 | /* |
||
149 | * Structure used in sigaltstack call. |
||
150 | */ |
||
151 | typedef struct sigaltstack { |
||
152 | void *ss_sp; /* Stack base or pointer. */ |
||
153 | int ss_flags; /* Flags. */ |
||
154 | size_t ss_size; /* Stack size. */ |
||
155 | } stack_t; |
||
156 | |||
4349 | Serge | 157 | #define SIG_SETMASK 0 /* set mask with sigprocmask() */ |
158 | #define SIG_BLOCK 1 /* set of signals to block */ |
||
159 | #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ |
||
160 | |||
161 | /* These depend upon the type of sigset_t, which right now |
||
162 | is always a long.. They're in the POSIX namespace, but |
||
163 | are not ANSI. */ |
||
164 | #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0) |
||
165 | #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0) |
||
166 | #define sigemptyset(what) (*(what) = 0, 0) |
||
167 | #define sigfillset(what) (*(what) = ~(0), 0) |
||
168 | #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0) |
||
169 | |||
170 | int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset)); |
||
171 | |||
172 | #if defined(_POSIX_THREADS) |
||
173 | int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset)); |
||
174 | #endif |
||
175 | |||
176 | #if defined(__CYGWIN__) || defined(__rtems__) |
||
177 | #undef sigaddset |
||
178 | #undef sigdelset |
||
179 | #undef sigemptyset |
||
180 | #undef sigfillset |
||
181 | #undef sigismember |
||
182 | |||
4921 | Serge | 183 | #ifdef _COMPILING_NEWLIB |
184 | int _EXFUN(_kill, (pid_t, int)); |
||
6099 | serge | 185 | #endif /* _COMPILING_NEWLIB */ |
186 | #endif /* __CYGWIN__ || __rtems__ */ |
||
187 | |||
4349 | Serge | 188 | int _EXFUN(kill, (pid_t, int)); |
6099 | serge | 189 | |
190 | #if defined(__CYGWIN__) || defined(__rtems__) |
||
4349 | Serge | 191 | int _EXFUN(killpg, (pid_t, int)); |
192 | int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); |
||
193 | int _EXFUN(sigaddset, (sigset_t *, const int)); |
||
194 | int _EXFUN(sigdelset, (sigset_t *, const int)); |
||
195 | int _EXFUN(sigismember, (const sigset_t *, int)); |
||
196 | int _EXFUN(sigfillset, (sigset_t *)); |
||
197 | int _EXFUN(sigemptyset, (sigset_t *)); |
||
198 | int _EXFUN(sigpending, (sigset_t *)); |
||
199 | int _EXFUN(sigsuspend, (const sigset_t *)); |
||
200 | int _EXFUN(sigpause, (int)); |
||
201 | |||
6099 | serge | 202 | #if defined(__CYGWIN__) || defined(__rtems__) |
203 | #if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 |
||
204 | int _EXFUN(sigaltstack, (const stack_t *__restrict, stack_t *__restrict)); |
||
205 | #endif |
||
206 | #endif |
||
207 | |||
4349 | Serge | 208 | #if defined(_POSIX_THREADS) |
209 | #ifdef __CYGWIN__ |
||
210 | # ifndef _CYGWIN_TYPES_H |
||
211 | # error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib. |
||
212 | # endif |
||
213 | #endif |
||
214 | int _EXFUN(pthread_kill, (pthread_t thread, int sig)); |
||
215 | #endif |
||
216 | |||
217 | #if defined(_POSIX_REALTIME_SIGNALS) |
||
218 | |||
219 | /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 |
||
220 | NOTE: P1003.1c/D10, p. 39 adds sigwait(). */ |
||
221 | |||
222 | int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info)); |
||
223 | int _EXFUN(sigtimedwait, |
||
224 | (const sigset_t *set, siginfo_t *info, const struct timespec *timeout) |
||
225 | ); |
||
226 | int _EXFUN(sigwait, (const sigset_t *set, int *sig)); |
||
227 | |||
228 | /* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */ |
||
229 | int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value)); |
||
230 | |||
231 | #endif /* defined(_POSIX_REALTIME_SIGNALS) */ |
||
232 | |||
233 | #endif /* defined(__CYGWIN__) || defined(__rtems__) */ |
||
234 | |||
235 | /* #endif __STRICT_ANSI__ */ |
||
236 | |||
237 | #if defined(___AM29K__) |
||
238 | /* These all need to be defined for ANSI C, but I don't think they are |
||
239 | meaningful. */ |
||
240 | #define SIGABRT 1 |
||
241 | #define SIGFPE 1 |
||
242 | #define SIGILL 1 |
||
243 | #define SIGINT 1 |
||
244 | #define SIGSEGV 1 |
||
245 | #define SIGTERM 1 |
||
246 | /* These need to be defined for POSIX, and some others do too. */ |
||
247 | #define SIGHUP 1 |
||
248 | #define SIGQUIT 1 |
||
249 | #define NSIG 2 |
||
250 | #elif defined(__GO32__) |
||
251 | #define SIGINT 1 |
||
252 | #define SIGKILL 2 |
||
253 | #define SIGPIPE 3 |
||
254 | #define SIGFPE 4 |
||
255 | #define SIGHUP 5 |
||
256 | #define SIGTERM 6 |
||
257 | #define SIGSEGV 7 |
||
258 | #define SIGTSTP 8 |
||
259 | #define SIGQUIT 9 |
||
260 | #define SIGTRAP 10 |
||
261 | #define SIGILL 11 |
||
262 | #define SIGEMT 12 |
||
263 | #define SIGALRM 13 |
||
264 | #define SIGBUS 14 |
||
265 | #define SIGLOST 15 |
||
266 | #define SIGSTOP 16 |
||
267 | #define SIGABRT 17 |
||
268 | #define SIGUSR1 18 |
||
269 | #define SIGUSR2 19 |
||
270 | #define NSIG 20 |
||
271 | #elif !defined(SIGTRAP) |
||
272 | #define SIGHUP 1 /* hangup */ |
||
273 | #define SIGINT 2 /* interrupt */ |
||
274 | #define SIGQUIT 3 /* quit */ |
||
275 | #define SIGILL 4 /* illegal instruction (not reset when caught) */ |
||
276 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ |
||
277 | #define SIGIOT 6 /* IOT instruction */ |
||
278 | #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ |
||
279 | #define SIGEMT 7 /* EMT instruction */ |
||
280 | #define SIGFPE 8 /* floating point exception */ |
||
281 | #define SIGKILL 9 /* kill (cannot be caught or ignored) */ |
||
282 | #define SIGBUS 10 /* bus error */ |
||
283 | #define SIGSEGV 11 /* segmentation violation */ |
||
284 | #define SIGSYS 12 /* bad argument to system call */ |
||
285 | #define SIGPIPE 13 /* write on a pipe with no one to read it */ |
||
286 | #define SIGALRM 14 /* alarm clock */ |
||
287 | #define SIGTERM 15 /* software termination signal from kill */ |
||
288 | |||
289 | #if defined(__rtems__) |
||
290 | #define SIGURG 16 /* urgent condition on IO channel */ |
||
291 | #define SIGSTOP 17 /* sendable stop signal not from tty */ |
||
292 | #define SIGTSTP 18 /* stop signal from tty */ |
||
293 | #define SIGCONT 19 /* continue a stopped process */ |
||
294 | #define SIGCHLD 20 /* to parent on child stop or exit */ |
||
295 | #define SIGCLD 20 /* System V name for SIGCHLD */ |
||
296 | #define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
||
297 | #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
||
298 | #define SIGIO 23 /* input/output possible signal */ |
||
299 | #define SIGPOLL SIGIO /* System V name for SIGIO */ |
||
300 | #define SIGWINCH 24 /* window changed */ |
||
301 | #define SIGUSR1 25 /* user defined signal 1 */ |
||
302 | #define SIGUSR2 26 /* user defined signal 2 */ |
||
303 | |||
304 | /* Real-Time Signals Range, P1003.1b-1993, p. 61 |
||
305 | NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX |
||
306 | (which is a minimum of 8) signals. |
||
307 | */ |
||
308 | #define SIGRTMIN 27 |
||
309 | #define SIGRTMAX 31 |
||
310 | #define __SIGFIRSTNOTRT SIGHUP |
||
311 | #define __SIGLASTNOTRT SIGUSR2 |
||
312 | |||
313 | #define NSIG 32 /* signal 0 implied */ |
||
314 | |||
315 | #elif defined(__svr4__) |
||
316 | /* svr4 specifics. different signals above 15, and sigaction. */ |
||
317 | #define SIGUSR1 16 |
||
318 | #define SIGUSR2 17 |
||
319 | #define SIGCLD 18 |
||
320 | #define SIGPWR 19 |
||
321 | #define SIGWINCH 20 |
||
322 | #define SIGPOLL 22 /* 20 for x.out binaries!!!! */ |
||
323 | #define SIGSTOP 23 /* sendable stop signal not from tty */ |
||
324 | #define SIGTSTP 24 /* stop signal from tty */ |
||
325 | #define SIGCONT 25 /* continue a stopped process */ |
||
326 | #define SIGTTIN 26 /* to readers pgrp upon background tty read */ |
||
327 | #define SIGTTOU 27 /* like TTIN for output if (tp->t_local<OSTOP) */ |
||
328 | #define NSIG 28 |
||
329 | #else |
||
330 | #define SIGURG 16 /* urgent condition on IO channel */ |
||
331 | #define SIGSTOP 17 /* sendable stop signal not from tty */ |
||
332 | #define SIGTSTP 18 /* stop signal from tty */ |
||
333 | #define SIGCONT 19 /* continue a stopped process */ |
||
334 | #define SIGCHLD 20 /* to parent on child stop or exit */ |
||
335 | #define SIGCLD 20 /* System V name for SIGCHLD */ |
||
336 | #define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
||
337 | #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
||
338 | #define SIGIO 23 /* input/output possible signal */ |
||
339 | #define SIGPOLL SIGIO /* System V name for SIGIO */ |
||
340 | #define SIGXCPU 24 /* exceeded CPU time limit */ |
||
341 | #define SIGXFSZ 25 /* exceeded file size limit */ |
||
342 | #define SIGVTALRM 26 /* virtual time alarm */ |
||
343 | #define SIGPROF 27 /* profiling time alarm */ |
||
344 | #define SIGWINCH 28 /* window changed */ |
||
345 | #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ |
||
346 | #define SIGUSR1 30 /* user defined signal 1 */ |
||
347 | #define SIGUSR2 31 /* user defined signal 2 */ |
||
348 | #define NSIG 32 /* signal 0 implied */ |
||
349 | #endif |
||
350 | #endif |
||
351 | |||
352 | #ifdef __cplusplus |
||
353 | } |
||
354 | #endif |
||
355 | |||
6099 | serge | 356 | #if defined(__CYGWIN__) |
357 | #if __POSIX_VISIBLE >= 200809 |
||
358 | #include |
||
359 | #endif |
||
360 | #endif |
||
361 | |||
4349 | Serge | 362 | #ifndef _SIGNAL_H_ |
363 | /* Some applications take advantage of the fact that |
||
364 | * and |
||
365 | #include |
||
366 | #endif |
||
367 | #endif /* _SYS_SIGNAL_H */(sig)))><(sig)))>(sig)),><(sig)),>(sig)),><(sig)),> |