Don't call ReadArgs() if started from WB.
[tangerine.git] / compiler / clib / include / signal.h
blobb0e4bae62534cecf6f09b4593c738bb04e2e8378
1 #ifndef _SIGNAL_H_
2 #define _SIGNAL_H_
4 /*
5 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
6 $Id$
8 System header file <signal.h>
9 Based on SUSv2 with help from C99.
12 #include <sys/_types.h>
13 #include <sys/cdefs.h>
15 typedef void __sighandler_t (int);
17 #define SIG_DFL ((__sighandler_t *)0) /* default signal handling */
18 #define SIG_IGN ((__sighandler_t *)1) /* ignore this signal */
19 #if !defined(_ANSI_SOURCE)
20 #define SIG_HOLD ((__sighandler_t *)2) /* hold this signal */
21 #endif
22 #define SIG_ERR ((__sighandler_t *)-1) /* return from signal() on error */
24 /* XXX Make sure that this agrees with the length in inttypes.h */
25 #if 0
26 typedef AROS_ATOMIC_TYPE sig_atomic_t;
27 #endif
29 /* Definitions to make signal manipulation easier. From FreeBSD */
30 #define _SIG_WORDS 4
31 #define _SIG_MAXSIG (_SIG_WORDS * 32)
32 #define _SIG_IDX(sig) ((sig) - 1)
33 #define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
34 #define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
35 #define _SIG_VALID(sig) ((sig) < _SIG_MAXSIG && (sig) > 0)
37 /* Almost all the remaining definitions are not part of ANSI C */
38 #if !defined(_ANSI_SOURCE)
40 typedef struct __sigset {
41 unsigned int __val[_SIG_WORDS];
42 } sigset_t;
44 #ifndef __AROS_PID_T_DECLARED
45 #define __AROS_PID_T_DECLARED
46 typedef __pid_t pid_t;
47 #endif
49 #endif /* !_ANSI_SOURCE */
51 /* Signal values */
52 #define SIGHUP 1 /* hangup */
53 #define SIGINT 2 /* interrupt */
54 #define SIGQUIT 3 /* quit */
55 #define SIGILL 4 /* illegal instr. */
56 #if !defined(_POSIX_SOURCE)
57 #define SIGTRAP 5 /* trace/breakpoint track */
58 #endif
59 #define SIGABRT 6 /* abort() */
60 #if !defined(_POSIX_SOURCE)
61 #define SIGEMT 7 /* EMT instruction (emulator trap) */
62 #endif
63 #define SIGFPE 8 /* floating point exception */
64 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
65 #if !defined(_POSIX_SOURCE)
66 #define SIGBUS 10 /* bus error */
67 #endif
68 #define SIGSEGV 11 /* segmentation violation */
69 #if !defined(_POSIX_SOURCE)
70 #define SIGSYS 12 /* non-existent system call */
71 #endif
72 #define SIGPIPE 13 /* write on a pipe without a reader */
73 #define SIGALRM 14 /* alarm clock */
74 #define SIGTERM 15 /* software termination */
75 #if !defined(_POSIX_SOURCE)
76 #define SIGURG 16 /* urgent IO condition */
77 #endif
78 #define SIGSTOP 17 /* sendable stop signal */
79 #define SIGTSTP 18 /* terminal stop signal */
80 #define SIGCONT 19 /* continue a stopped process */
81 #define SIGCHLD 20 /* to parent on child stop or exit */
82 #define SIGTTIN 21 /* to reader to background tty read */
83 #define SIGTTOU 22 /* to writer on background tty write */
84 #if !defined(_POSIX_SOURCE)
85 #define SIGXCPU 23 /* exceeded CPU time limit */
86 #define SIGXFSZ 24 /* exceeded file size limit */
87 #define SIGVTALRM 25 /* virtual timer alarm */
88 #define SIGPROF 26 /* profiling time alarm */
89 #define SIGWINCH 27 /* window size changes */
90 #endif
91 #define SIGUSR1 28 /* user defined signal 1 */
92 #define SIGUSR2 29 /* user defined signal 2 */
94 #if !defined(_POSIX_SOURCE)
95 /* BSD defines SIGIO and SIGINFO, we should probably include these */
96 #define SIGIO 30 /* IO event */
97 #define SIGINFO 31 /* terminal info request */
98 #endif
100 #if defined(_P1003_1B_VISIBLE)
102 /* Real time signals as specified by POSIX 1003.1B */
103 #define SIGRTMIN 33
104 #define SIGRT1 33
105 #define SIGRT2 34
106 #define SIGRT3 35
107 #define SIGRT4 36
108 #define SIGRT5 37
109 #define SIGRT6 38
110 #define SIGRT7 39
111 #define SIGRT8 40
112 #define SIGRT9 41
113 #define SIGRT10 42
114 #define SIGRT11 43
115 #define SIGRT12 44
116 #define SIGRT13 45
117 #define SIGRT14 46
118 #define SIGRT15 47
119 #define SIGRT16 48
120 #define SIGRT17 49
121 #define SIGRT18 50
122 #define SIGRT19 51
123 #define SIGRT20 52
124 #define SIGRT21 53
125 #define SIGRT22 54
126 #define SIGRT23 55
127 #define SIGRT24 56
128 #define SIGRT25 57
129 #define SIGRT26 58
130 #define SIGRT27 59
131 #define SIGRT28 60
132 #define SIGRT29 61
133 #define SIGRT30 62
134 #define SIGRT31 63
135 #define SIGRT32 64
136 #define SIGRTMAX 64
138 #define RTSIG_MAX 32
140 /* Value passed to sigevent() SIGEV_THREAD functions */
141 union sigval
143 int sigval_int;
144 void * sigval_ptr;
148 sigevent() is an advanced call that allows a process to request the
149 system to perform more advanced signal delivery that calling signal
150 handlers.
152 AROS allows for signals to be queued, delivered normally, or by
153 creating a new thread and calling a function.
155 See the sigevent() manual page for more information.
157 struct sigevent
159 int sigev_notify; /* notification type */
160 union {
161 int __sigev_signo; /* signal number */
162 struct {
163 void (*__sigev_notify_function)(union sigval);
164 } __sigev_notify_call; /* call a function */
165 } __sigev_u;
166 union sigval sigev_value; /* signal value */
169 /* Send a signal to the process */
170 #define sigev_signo __sigev_u.__sigev_signo
173 Call a function.
174 XXX Note that we do not support sigev_notify_attributes
176 #define sigev_notify_function \
177 __sigev_u.__sigev_notify_call.__sigenv_notify_function
179 #define SIGEV_NONE 0 /* No notification */
180 #define SIGEV_SIGNAL 1 /* Generate a queued signal */
181 #define SIGEV_THREAD 2 /* Call a notification function */
184 siginfo_t is delivered to sigaction() style signal handlers.
185 It's part of the POSIX Realtime Extension
187 typedef struct __siginfo
189 int si_signo; /* signal number */
190 int si_errno; /* errno value */
191 int si_code; /* signal code */
192 pid_t si_pid; /* sending process ID */
193 __uid_t si_uid; /* user ID of sending process XXX */
194 void * si_addr; /* address of faulting instruction */
195 int si_status; /* exit value or signal */
196 long si_band; /* band event for SIGPOLL */
197 union sigval si_value; /* signal value */
198 } siginfo_t;
200 #endif /* P1003_1B_VISIBLE */
202 #if !defined(_ANSI_SOURCE)
204 struct __siginfo;
207 sigaction() provides an advanced interface for setting signal handling
208 options.
210 struct sigaction
212 union {
213 void (*__sa_handler)(int);
214 void (*__sa_sigaction)(int, struct __siginfo *, void *);
215 } __sigaction_u; /* signal handler */
216 int sa_flags; /* see below */
217 sigset_t sa_mask; /* signal mask to apply */
220 #define sa_handler __sigaction_u.__sa_handler
222 #if !defined(_POSIX_SOURCE)
224 #define __need_size_t
225 #include <stddef.h>
227 /* if SA_SIGINFO is set, use sa_sigaction rather than sa_handler */
228 #define sa_sigaction __sigaction_u.__sa_sigaction
230 #define SA_NOCLDSTOP 0x0001
231 #define SA_ONSTACK 0x0002
232 #define SA_RESETHAND 0x0004
233 #define SA_RESTART 0x0008
234 #define SA_SIGINFO 0x0010
235 #define SA_NOCLDWAIT 0x0020
236 #define SA_NODEFER 0x0040
238 /* For sigaltstack() and the sigaltstack structure */
239 typedef struct sigaltstack
241 void *ss_sp; /* signal stack base */
242 size_t ss_size; /* signal stack size */
243 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
244 } stack_t;
246 #define SS_ONSTACK 0x0001
247 #define SS_DISABLE 0x0002
249 struct sigstack
251 int ss_onstack; /* non-zero when signal stack in use */
252 void *ss_sp; /* signal stack pointer */
255 #define MINSIGSTKSZ 8192
256 #define SIGSTKSZ (MINSIGSTKSZ + 40960)
258 /* XXX - We need ucontext_t */
260 /* Reasons why a signal was generated */
262 /* For SIGILL */
263 #define ILL_ILLOPC 1 /* illegal opcode */
264 #define ILL_ILLOPN 2 /* illegal operand */
265 #define ILL_ILLADR 3 /* illegal address mode */
266 #define ILL_ILLTRP 4 /* illegal trap */
267 #define ILL_PRVOPC 5 /* priviledged opcode */
268 #define ILL_PRVREG 6 /* priviledged register */
269 #define ILL_COPROC 7 /* coprocessor error */
270 #define ILL_BADSTACK 8 /* internal stack error */
272 /* For SIGFPE */
273 #define FPE_INTDIV 1 /* integer divide by zero */
274 #define FPE_INTOVF 2 /* integer overflow */
275 #define FPE_FLTDIV 3 /* floating point divide by zero */
276 #define FPE_FLTOVF 4 /* floating point overflow */
277 #define FPE_FLTUND 5 /* floating point underflow */
278 #define FPE_FLTRES 6 /* floating point inexact result */
279 #define FPE_FLTINV 7 /* invalid floating point operation */
280 #define FPE_FLTSUB 8 /* subscript out of range */
282 /* For SIGSEGV */
283 #define SEGV_MAPERR 1 /* address not mapped to object */
284 #define SEGV_ACCERR 2 /* invalid permissions for object */
286 /* For SIGBUS */
287 #define BUS_ADRALN 1 /* Address alignment */
288 #define BUS_ADRERR 2 /* Bus address error */
289 #define BUS_OBJERR 3 /* object specific hardware error */
291 /* For SIGTRAP */
292 #define TRAP_BRKPT 1 /* Process breakpoint */
293 #define TRAP_TRACE 2 /* Process trace trap */
295 /* For SIGCHLD */
296 #define CLD_EXITED 1 /* Child has exited */
297 #define CLD_KILL 2 /* Child terminated abnormally */
298 #define CLD_CORE 3 /* Child dumped core */
299 #define CLD_TRAPPED 4 /* Traced child has trapped */
300 #define CLD_STOPPED 5 /* Traced child has stopped */
301 #define CLD_CONTINUED 6 /* Traced child has continued */
303 /* For SIGPOLL */
304 #define POLL_IN 1 /* data input available */
305 #define POLL_OUT 2 /* data output available */
306 #define POLL_MSG 3 /* input message available */
307 #define POLL_ERR 4 /* I/O error */
308 #define POLL_PRI 5 /* high priority input available */
309 #define POLL_HUP 6 /* device disconnected */
311 /* Others */
312 #define SI_USER 0x10001 /* Signal sent by kill() */
313 #define SI_QUEUE 0x10002 /* Signal sent by sigqueue() */
314 #define SI_TIMER 0x10003 /* Signal sent by timer */
315 #define SI_ASYNCIO 0x10004 /* Signal sent by async I/O */
316 #define SI_MESGQ 0x10005 /* Signal generated by message queue */
318 /* Tag for struct timespec */
319 struct timespec;
321 #endif /* !_POSIX_SOURCE */
323 /* Flags for sigprocmask() */
324 #define SIG_BLOCK 1
325 #define SIG_UNBLOCK 2
326 #define SIG_SETMASK 34
328 #endif /* !_ANSI_SOURCE */
330 /* Function Prototypes */
331 __BEGIN_DECLS
333 int raise(int);
334 __sighandler_t *signal(int, __sighandler_t *);
336 #if !defined(_ANSI_SOURCE)
337 int kill(pid_t, int);
339 int sigaction(int, const struct sigaction *, struct sigaction *);
340 int sigaddset(sigset_t *, int);
341 int sigdelset(sigset_t *, int);
342 int sigemptyset(sigset_t *);
343 int sigfillset(sigset_t *);
344 /* NOTIMPL int sighold(int); */
345 /* NOTIMPL int sigignore(int); */
346 int sigismember(const sigset_t *, int);
347 int sigpending(sigset_t *);
348 int sigprocmask(int, const sigset_t *, sigset_t *);
349 /* NOTIMPL int sigrelse(int); */
350 /* NOTIMPL int sigset(__sighandler_t *, int); */
351 int sigsuspend(const sigset_t *);
352 /* NOTIMPL int sigwait(const sigset_t *, int *); */
354 #if !defined(_POSIX_SOURCE)
355 /* NOTIMPL int killpg(pid_t, int); */
356 /* NOTIMPL int sigaltstack(const stack_t *, stack_t *); */
357 /* NOTIMPL int siginterrupt(int); */
358 /* NOTIMPL int sigpause(int); */
359 #endif /* !_POSIX_SOURCE */
361 #if defined(_P1003_1B_VISIBLE)
362 /* NOTIMPL int sigqueue(pid_t, int, const union sigval); */
363 /* NOTIMPL int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *); */
364 /* NOTIMPL int sigwaitinfo(const sigset_t *, siginfo_t *); */
365 #endif /* _P1003_1B */
367 #endif /* !_ANSI_SOURCE */
369 __END_DECLS
371 #endif /* _SIGNAL_H_ */