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