e9838461031c235cd52472fbbe959f43700119ee
[lunaix-os.git] / lunaix-os / includes / lunaix / signal.h
1 #ifndef __LUNAIX_SIGNAL_H
2 #define __LUNAIX_SIGNAL_H
3
4 #include <usr/lunaix/signal_defs.h>
5
6 #define _SIG_NUM 16
7
8 #define _SIG_PENDING(bitmap, sig) ((bitmap) & (1 << (sig)))
9
10 #define _SIGSEGV SIGSEGV
11 #define _SIGALRM SIGALRM
12 #define _SIGCHLD SIGCHLD
13 #define _SIGCLD SIGCLD
14 #define _SIGINT SIGINT
15 #define _SIGKILL SIGKILL
16 #define _SIGSTOP SIGSTOP
17 #define _SIGCONT SIGCONT
18 #define _SIGTERM SIGTERM
19 #define _SIG_BLOCK SIG_BLOCK
20 #define _SIG_UNBLOCK SIG_UNBLOCK
21 #define _SIG_SETMASK SIG_SETMASK
22
23 #define sigset(num) (1 << (num))
24 #define sigset_add(set, num) (set = set | sigset(num))
25 #define sigset_test(set, num) (set & sigset(num))
26 #define sigset_clear(set, num) ((set) = (set) & ~sigset(num))
27 #define sigset_union(set, set2) ((set) = (set) | (set2))
28 #define sigset_intersect(set, set2) ((set) = (set) & (set2))
29
30 struct sigact
31 {
32     sigset_t sa_mask;
33     void* sa_actor;
34     void* sa_handler;
35     pid_t sender;
36 };
37
38 struct sigregistry {
39     struct sigact* signals[_SIG_NUM];
40 };
41
42 struct sigctx
43 {
44     sigset_t sig_pending;
45     sigset_t sig_mask;
46     signum_t sig_active;
47     signum_t sig_order[_SIG_NUM];
48 };
49
50 int
51 signal_send(pid_t pid, signum_t signum);
52
53 void
54 signal_dup_context(struct sigctx* dest_ctx);
55
56 void
57 signal_dup_registry(struct sigregistry* dest_reg);
58
59 void
60 signal_reset_context(struct sigctx* sigctx);
61
62 void
63 signal_reset_registry(struct sigregistry* sigreg);
64
65 void
66 signal_free_registry(struct sigregistry* sigreg);
67
68 #endif /* __LUNAIX_SIGNAL_H */