comparison druntime/import/stdc/posix/signal.d @ 760:6f33b427bfd1

Seems like hg ignores .di files, so I missed a bunch of stuff. complete druntime should be there now :)
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 12 Nov 2008 00:19:18 +0100
parents
children
comparison
equal deleted inserted replaced
759:d3eb054172f9 760:6f33b427bfd1
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Public Domain
5 * License: Public Domain
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 */
9 module stdc.posix.signal;
10
11 private import stdc.posix.config;
12 public import stdc.signal;
13 public import stdc.stddef; // for size_t
14 public import stdc.posix.sys.types; // for pid_t
15 //public import stdc.posix.time; // for timespec, now defined here
16
17 extern (C):
18
19 private alias void function(int) sigfn_t;
20 private alias void function(int, siginfo_t*, void*) sigactfn_t;
21
22 //
23 // Required
24 //
25 /*
26 SIG_DFL (defined in stdc.signal)
27 SIG_ERR (defined in stdc.signal)
28 SIG_IGN (defined in stdc.signal)
29
30 sig_atomic_t (defined in stdc.signal)
31
32 SIGEV_NONE
33 SIGEV_SIGNAL
34 SIGEV_THREAD
35
36 union sigval
37 {
38 int sival_int;
39 void* sival_ptr;
40 }
41
42 SIGRTMIN
43 SIGRTMAX
44
45 SIGABRT (defined in stdc.signal)
46 SIGALRM
47 SIGBUS
48 SIGCHLD
49 SIGCONT
50 SIGFPE (defined in stdc.signal)
51 SIGHUP
52 SIGILL (defined in stdc.signal)
53 SIGINT (defined in stdc.signal)
54 SIGKILL
55 SIGPIPE
56 SIGQUIT
57 SIGSEGV (defined in stdc.signal)
58 SIGSTOP
59 SIGTERM (defined in stdc.signal)
60 SIGTSTP
61 SIGTTIN
62 SIGTTOU
63 SIGUSR1
64 SIGUSR2
65 SIGURG
66
67 struct sigaction_t
68 {
69 sigfn_t sa_handler;
70 sigset_t sa_mask;
71 sigactfn_t sa_sigaction;
72 }
73
74 sigfn_t signal(int sig, sigfn_t func); (defined in stdc.signal)
75 int raise(int sig); (defined in stdc.signal)
76 */
77
78 //SIG_DFL (defined in stdc.signal)
79 //SIG_ERR (defined in stdc.signal)
80 //SIG_IGN (defined in stdc.signal)
81
82 //sig_atomic_t (defined in stdc.signal)
83
84 enum
85 {
86 SIGEV_SIGNAL,
87 SIGEV_NONE,
88 SIGEV_THREAD
89 }
90
91 union sigval
92 {
93 int sival_int;
94 void* sival_ptr;
95 }
96
97 private extern (C) int __libc_current_sigrtmin();
98 private extern (C) int __libc_current_sigrtmax();
99
100 alias __libc_current_sigrtmin SIGRTMIN;
101 alias __libc_current_sigrtmax SIGRTMAX;
102
103 version( linux )
104 {
105 //SIGABRT (defined in stdc.signal)
106 const SIGALRM = 14;
107 const SIGBUS = 7;
108 const SIGCHLD = 17;
109 const SIGCONT = 18;
110 //SIGFPE (defined in stdc.signal)
111 const SIGHUP = 1;
112 //SIGILL (defined in stdc.signal)
113 //SIGINT (defined in stdc.signal)
114 const SIGKILL = 9;
115 const SIGPIPE = 13;
116 const SIGQUIT = 3;
117 //SIGSEGV (defined in stdc.signal)
118 const SIGSTOP = 19;
119 //SIGTERM (defined in stdc.signal)
120 const SIGTSTP = 20;
121 const SIGTTIN = 21;
122 const SIGTTOU = 22;
123 const SIGUSR1 = 10;
124 const SIGUSR2 = 12;
125 const SIGURG = 23;
126 }
127 else version( darwin )
128 {
129 //SIGABRT (defined in stdc.signal)
130 const SIGALRM = 14;
131 const SIGBUS = 10;
132 const SIGCHLD = 20;
133 const SIGCONT = 19;
134 //SIGFPE (defined in stdc.signal)
135 const SIGHUP = 1;
136 //SIGILL (defined in stdc.signal)
137 //SIGINT (defined in stdc.signal)
138 const SIGKILL = 9;
139 const SIGPIPE = 13;
140 const SIGQUIT = 3;
141 //SIGSEGV (defined in stdc.signal)
142 const SIGSTOP = 17;
143 //SIGTERM (defined in stdc.signal)
144 const SIGTSTP = 18;
145 const SIGTTIN = 21;
146 const SIGTTOU = 22;
147 const SIGUSR1 = 30;
148 const SIGUSR2 = 31;
149 const SIGURG = 16;
150 }
151 else version( freebsd )
152 {
153 //SIGABRT (defined in stdc.signal)
154 const SIGALRM = 14;
155 const SIGBUS = 10;
156 const SIGCHLD = 20;
157 const SIGCONT = 19;
158 //SIGFPE (defined in stdc.signal)
159 const SIGHUP = 1;
160 //SIGILL (defined in stdc.signal)
161 //SIGINT (defined in stdc.signal)
162 const SIGKILL = 9;
163 const SIGPIPE = 13;
164 const SIGQUIT = 3;
165 //SIGSEGV (defined in stdc.signal)
166 const SIGSTOP = 17;
167 //SIGTERM (defined in stdc.signal)
168 const SIGTSTP = 18;
169 const SIGTTIN = 21;
170 const SIGTTOU = 22;
171 const SIGUSR1 = 30;
172 const SIGUSR2 = 31;
173 const SIGURG = 16;
174 }
175
176 struct sigaction_t
177 {
178 static if( true /* __USE_POSIX199309 */ )
179 {
180 union
181 {
182 sigfn_t sa_handler;
183 sigactfn_t sa_sigaction;
184 }
185 }
186 else
187 {
188 sigfn_t sa_handler;
189 }
190 sigset_t sa_mask;
191 int sa_flags;
192
193 version( darwin ) {} else {
194 void function() sa_restorer;
195 }
196 }
197
198 //
199 // C Extension (CX)
200 //
201 /*
202 SIG_HOLD
203
204 sigset_t
205 pid_t (defined in sys.types)
206
207 SIGABRT (defined in stdc.signal)
208 SIGFPE (defined in stdc.signal)
209 SIGILL (defined in stdc.signal)
210 SIGINT (defined in stdc.signal)
211 SIGSEGV (defined in stdc.signal)
212 SIGTERM (defined in stdc.signal)
213
214 SA_NOCLDSTOP (CX|XSI)
215 SIG_BLOCK
216 SIG_UNBLOCK
217 SIG_SETMASK
218
219 struct siginfo_t
220 {
221 int si_signo;
222 int si_code;
223
224 version( XSI )
225 {
226 int si_errno;
227 pid_t si_pid;
228 uid_t si_uid;
229 void* si_addr;
230 int si_status;
231 c_long si_band;
232 }
233 version( RTS )
234 {
235 sigval si_value;
236 }
237 }
238
239 SI_USER
240 SI_QUEUE
241 SI_TIMER
242 SI_ASYNCIO
243 SI_MESGQ
244
245 int kill(pid_t, int);
246 int sigaction(int, in sigaction_t*, sigaction_t*);
247 int sigaddset(sigset_t*, int);
248 int sigdelset(sigset_t*, int);
249 int sigemptyset(sigset_t*);
250 int sigfillset(sigset_t*);
251 int sigismember(in sigset_t*, int);
252 int sigpending(sigset_t*);
253 int sigprocmask(int, in sigset_t*, sigset_t*);
254 int sigsuspend(in sigset_t*);
255 int sigwait(in sigset_t*, int*);
256 */
257
258 version( linux )
259 {
260 const SIG_HOLD = cast(sigfn_t) 1;
261
262 private const _SIGSET_NWORDS = 1024 / (8 * c_ulong.sizeof);
263
264 struct sigset_t
265 {
266 c_ulong[_SIGSET_NWORDS] __val;
267 }
268
269 // pid_t (defined in sys.types)
270
271 //SIGABRT (defined in stdc.signal)
272 //SIGFPE (defined in stdc.signal)
273 //SIGILL (defined in stdc.signal)
274 //SIGINT (defined in stdc.signal)
275 //SIGSEGV (defined in stdc.signal)
276 //SIGTERM (defined in stdc.signal)
277
278 const SA_NOCLDSTOP = 1; // (CX|XSI)
279
280 const SIG_BLOCK = 0;
281 const SIG_UNBLOCK = 1;
282 const SIG_SETMASK = 2;
283
284 private const __SI_MAX_SIZE = 128;
285
286 static if( false /* __WORDSIZE == 64 */ )
287 {
288 private const __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 4);
289 }
290 else
291 {
292 private const __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 3);
293 }
294
295 struct siginfo_t
296 {
297 int si_signo; // Signal number
298 int si_errno; // If non-zero, an errno value associated with
299 // this signal, as defined in <errno.h>
300 int si_code; // Signal code
301
302 union _sifields_t
303 {
304 int _pad[__SI_PAD_SIZE];
305
306 // kill()
307 struct _kill_t
308 {
309 pid_t si_pid; // Sending process ID
310 uid_t si_uid; // Real user ID of sending process
311 } _kill_t _kill;
312
313 // POSIX.1b timers.
314 struct _timer_t
315 {
316 int si_tid; // Timer ID
317 int si_overrun; // Overrun count
318 sigval si_sigval; // Signal value
319 } _timer_t _timer;
320
321 // POSIX.1b signals
322 struct _rt_t
323 {
324 pid_t si_pid; // Sending process ID
325 uid_t si_uid; // Real user ID of sending process
326 sigval si_sigval; // Signal value
327 } _rt_t _rt;
328
329 // SIGCHLD
330 struct _sigchild_t
331 {
332 pid_t si_pid; // Which child
333 uid_t si_uid; // Real user ID of sending process
334 int si_status; // Exit value or signal
335 clock_t si_utime;
336 clock_t si_stime;
337 } _sigchild_t _sigchld;
338
339 // SIGILL, SIGFPE, SIGSEGV, SIGBUS
340 struct _sigfault_t
341 {
342 void* si_addr; // Faulting insn/memory ref
343 } _sigfault_t _sigfault;
344
345 // SIGPOLL
346 struct _sigpoll_t
347 {
348 c_long si_band; // Band event for SIGPOLL
349 int si_fd;
350 } _sigpoll_t _sigpoll;
351 } _sifields_t _sifields;
352 }
353
354 enum
355 {
356 SI_ASYNCNL = -60,
357 SI_TKILL = -6,
358 SI_SIGIO,
359 SI_ASYNCIO,
360 SI_MESGQ,
361 SI_TIMER,
362 SI_QUEUE,
363 SI_USER,
364 SI_KERNEL = 0x80
365 }
366
367 int kill(pid_t, int);
368 int sigaction(int, in sigaction_t*, sigaction_t*);
369 int sigaddset(sigset_t*, int);
370 int sigdelset(sigset_t*, int);
371 int sigemptyset(sigset_t*);
372 int sigfillset(sigset_t*);
373 int sigismember(in sigset_t*, int);
374 int sigpending(sigset_t*);
375 int sigprocmask(int, in sigset_t*, sigset_t*);
376 int sigsuspend(in sigset_t*);
377 int sigwait(in sigset_t*, int*);
378 }
379 else version( darwin )
380 {
381 //SIG_HOLD
382
383 alias uint sigset_t;
384 // pid_t (defined in sys.types)
385
386 //SIGABRT (defined in stdc.signal)
387 //SIGFPE (defined in stdc.signal)
388 //SIGILL (defined in stdc.signal)
389 //SIGINT (defined in stdc.signal)
390 //SIGSEGV (defined in stdc.signal)
391 //SIGTERM (defined in stdc.signal)
392
393 //SA_NOCLDSTOP (CX|XSI)
394
395 //SIG_BLOCK
396 //SIG_UNBLOCK
397 //SIG_SETMASK
398
399 struct siginfo_t
400 {
401 int si_signo;
402 int si_errno;
403 int si_code;
404 pid_t si_pid;
405 uid_t si_uid;
406 int si_status;
407 void* si_addr;
408 sigval si_value;
409 int si_band;
410 uint pad[7];
411 }
412
413 //SI_USER
414 //SI_QUEUE
415 //SI_TIMER
416 //SI_ASYNCIO
417 //SI_MESGQ
418
419 int kill(pid_t, int);
420 int sigaction(int, in sigaction_t*, sigaction_t*);
421 int sigaddset(sigset_t*, int);
422 int sigdelset(sigset_t*, int);
423 int sigemptyset(sigset_t*);
424 int sigfillset(sigset_t*);
425 int sigismember(in sigset_t*, int);
426 int sigpending(sigset_t*);
427 int sigprocmask(int, in sigset_t*, sigset_t*);
428 int sigsuspend(in sigset_t*);
429 int sigwait(in sigset_t*, int*);
430 }
431 else version( freebsd )
432 {
433 struct sigset_t
434 {
435 uint __bits[4];
436 }
437
438 struct siginfo_t
439 {
440 int si_signo;
441 int si_errno;
442 int si_code;
443 pid_t si_pid;
444 uid_t si_uid;
445 int si_status;
446 void* si_addr;
447 sigval si_value;
448 union __reason
449 {
450 struct __fault
451 {
452 int _trapno;
453 }
454 __fault _fault;
455 struct __timer
456 {
457 int _timerid;
458 int _overrun;
459 }
460 __timer _timer;
461 struct __mesgq
462 {
463 int _mqd;
464 }
465 __mesgq _mesgq;
466 struct __poll
467 {
468 c_long _band;
469 }
470 __poll _poll;
471 struct ___spare___
472 {
473 c_long __spare1__;
474 int[7] __spare2__;
475 }
476 ___spare___ __spare__;
477 }
478 __reason _reason;
479 }
480
481 int kill(pid_t, int);
482 int sigaction(int, in sigaction_t*, sigaction_t);
483 int sigaddset(sigset_t*, int);
484 int sigdelset(sigset_t*, int);
485 int sigemptyset(sigset_t *);
486 int sigfillset(sigset_t *);
487 int sigismember(in sigset_t *, int);
488 int sigpending(sigset_t *);
489 int sigprocmask(int, in sigset_t*, sigset_t*);
490 int sigsuspend(in sigset_t *);
491 int sigwait(in sigset_t*, int*);
492 }
493
494
495 //
496 // XOpen (XSI)
497 //
498 /*
499 SIGPOLL
500 SIGPROF
501 SIGSYS
502 SIGTRAP
503 SIGVTALRM
504 SIGXCPU
505 SIGXFSZ
506
507 SA_ONSTACK
508 SA_RESETHAND
509 SA_RESTART
510 SA_SIGINFO
511 SA_NOCLDWAIT
512 SA_NODEFER
513 SS_ONSTACK
514 SS_DISABLE
515 MINSIGSTKSZ
516 SIGSTKSZ
517
518 ucontext_t // from ucontext
519 mcontext_t // from ucontext
520
521 struct stack_t
522 {
523 void* ss_sp;
524 size_t ss_size;
525 int ss_flags;
526 }
527
528 struct sigstack
529 {
530 int ss_onstack;
531 void* ss_sp;
532 }
533
534 ILL_ILLOPC
535 ILL_ILLOPN
536 ILL_ILLADR
537 ILL_ILLTRP
538 ILL_PRVOPC
539 ILL_PRVREG
540 ILL_COPROC
541 ILL_BADSTK
542
543 FPE_INTDIV
544 FPE_INTOVF
545 FPE_FLTDIV
546 FPE_FLTOVF
547 FPE_FLTUND
548 FPE_FLTRES
549 FPE_FLTINV
550 FPE_FLTSUB
551
552 SEGV_MAPERR
553 SEGV_ACCERR
554
555 BUS_ADRALN
556 BUS_ADRERR
557 BUS_OBJERR
558
559 TRAP_BRKPT
560 TRAP_TRACE
561
562 CLD_EXITED
563 CLD_KILLED
564 CLD_DUMPED
565 CLD_TRAPPED
566 CLD_STOPPED
567 CLD_CONTINUED
568
569 POLL_IN
570 POLL_OUT
571 POLL_MSG
572 POLL_ERR
573 POLL_PRI
574 POLL_HUP
575
576 sigfn_t bsd_signal(int sig, sigfn_t func);
577 sigfn_t sigset(int sig, sigfn_t func);
578
579 int killpg(pid_t, int);
580 int sigaltstack(in stack_t*, stack_t*);
581 int sighold(int);
582 int sigignore(int);
583 int siginterrupt(int, int);
584 int sigpause(int);
585 int sigrelse(int);
586 */
587
588 version( linux )
589 {
590 const SIGPOLL = 29;
591 const SIGPROF = 27;
592 const SIGSYS = 31;
593 const SIGTRAP = 5;
594 const SIGVTALRM = 26;
595 const SIGXCPU = 24;
596 const SIGXFSZ = 25;
597
598 const SA_ONSTACK = 0x08000000;
599 const SA_RESETHAND = 0x80000000;
600 const SA_RESTART = 0x10000000;
601 const SA_SIGINFO = 4;
602 const SA_NOCLDWAIT = 2;
603 const SA_NODEFER = 0x40000000;
604 const SS_ONSTACK = 1;
605 const SS_DISABLE = 2;
606 const MINSIGSTKSZ = 2048;
607 const SIGSTKSZ = 8192;
608
609 //ucontext_t (defined in stdc.posix.ucontext)
610 //mcontext_t (defined in stdc.posix.ucontext)
611
612 struct stack_t
613 {
614 void* ss_sp;
615 int ss_flags;
616 size_t ss_size;
617 }
618
619 struct sigstack
620 {
621 void* ss_sp;
622 int ss_onstack;
623 }
624
625 enum
626 {
627 ILL_ILLOPC = 1,
628 ILL_ILLOPN,
629 ILL_ILLADR,
630 ILL_ILLTRP,
631 ILL_PRVOPC,
632 ILL_PRVREG,
633 ILL_COPROC,
634 ILL_BADSTK
635 }
636
637 enum
638 {
639 FPE_INTDIV = 1,
640 FPE_INTOVF,
641 FPE_FLTDIV,
642 FPE_FLTOVF,
643 FPE_FLTUND,
644 FPE_FLTRES,
645 FPE_FLTINV,
646 FPE_FLTSUB
647 }
648
649 enum
650 {
651 SEGV_MAPERR = 1,
652 SEGV_ACCERR
653 }
654
655 enum
656 {
657 BUS_ADRALN = 1,
658 BUS_ADRERR,
659 BUS_OBJERR
660 }
661
662 enum
663 {
664 TRAP_BRKPT = 1,
665 TRAP_TRACE
666 }
667
668 enum
669 {
670 CLD_EXITED = 1,
671 CLD_KILLED,
672 CLD_DUMPED,
673 CLD_TRAPPED,
674 CLD_STOPPED,
675 CLD_CONTINUED
676 }
677
678 enum
679 {
680 POLL_IN = 1,
681 POLL_OUT,
682 POLL_MSG,
683 POLL_ERR,
684 POLL_PRI,
685 POLL_HUP
686 }
687
688 sigfn_t bsd_signal(int sig, sigfn_t func);
689 sigfn_t sigset(int sig, sigfn_t func);
690
691 int killpg(pid_t, int);
692 int sigaltstack(in stack_t*, stack_t*);
693 int sighold(int);
694 int sigignore(int);
695 int siginterrupt(int, int);
696 int sigpause(int);
697 int sigrelse(int);
698 }
699
700 //
701 // Timer (TMR)
702 //
703 /*
704 NOTE: This should actually be defined in stdc.posix.time.
705 It is defined here instead to break a circular import.
706
707 struct timespec
708 {
709 time_t tv_sec;
710 int tv_nsec;
711 }
712 */
713
714 version( linux )
715 {
716 struct timespec
717 {
718 time_t tv_sec;
719 c_long tv_nsec;
720 }
721 }
722 else version( darwin )
723 {
724 struct timespec
725 {
726 time_t tv_sec;
727 c_long tv_nsec;
728 }
729 }
730 else version( freebsd )
731 {
732 struct timespec
733 {
734 time_t tv_sec;
735 c_long tv_nsec;
736 }
737 }
738
739 //
740 // Realtime Signals (RTS)
741 //
742 /*
743 struct sigevent
744 {
745 int sigev_notify;
746 int sigev_signo;
747 sigval sigev_value;
748 void(*)(sigval) sigev_notify_function;
749 pthread_attr_t* sigev_notify_attributes;
750 }
751
752 int sigqueue(pid_t, int, in sigval);
753 int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
754 int sigwaitinfo(in sigset_t*, siginfo_t*);
755 */
756
757 version( linux )
758 {
759 private const __SIGEV_MAX_SIZE = 64;
760
761 static if( false /* __WORDSIZE == 64 */ )
762 {
763 private const __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 4);
764 }
765 else
766 {
767 private const __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 3);
768 }
769
770 struct sigevent
771 {
772 sigval sigev_value;
773 int sigev_signo;
774 int sigev_notify;
775
776 union _sigev_un_t
777 {
778 int[__SIGEV_PAD_SIZE] _pad;
779 pid_t _tid;
780
781 struct _sigev_thread_t
782 {
783 void function(sigval) _function;
784 void* _attribute;
785 } _sigev_thread_t _sigev_thread;
786 } _sigev_un_t _sigev_un;
787 }
788
789 int sigqueue(pid_t, int, in sigval);
790 int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
791 int sigwaitinfo(in sigset_t*, siginfo_t*);
792 }
793 else version( freebsd )
794 {
795 struct sigevent
796 {
797 int sigev_notify;
798 int sigev_signo;
799 sigval sigev_value;
800 union _sigev_un
801 {
802 lwpid_t _threadid;
803 struct _sigev_thread {
804 void function(sigval) _function;
805 void* _attribute;
806 }
807 c_long[8] __spare__;
808 }
809 }
810
811 int sigqueue(pid_t, int, in sigval);
812 int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
813 int sigwaitinfo(in sigset_t*, siginfo_t*);
814 }
815 //
816 // Threads (THR)
817 //
818 /*
819 int pthread_kill(pthread_t, int);
820 int pthread_sigmask(int, in sigset_t*, sigset_t*);
821 */
822
823 version( linux )
824 {
825 int pthread_kill(pthread_t, int);
826 int pthread_sigmask(int, in sigset_t*, sigset_t*);
827 }
828 else version( darwin )
829 {
830 int pthread_kill(pthread_t, int);
831 int pthread_sigmask(int, in sigset_t*, sigset_t*);
832 }
833 else version( freebsd )
834 {
835 int pthread_kill(pthread_t, int);
836 int pthread_sigmask(int, in sigset_t*, sigset_t*);
837 }