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