X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/aa8afd3a17a7433230b76a1910ab3ddb83bcd227..refs/heads/nov/revmap:/lunaix-os/includes/lunaix/signal.h diff --git a/lunaix-os/includes/lunaix/signal.h b/lunaix-os/includes/lunaix/signal.h index d1f7041..556823b 100644 --- a/lunaix-os/includes/lunaix/signal.h +++ b/lunaix-os/includes/lunaix/signal.h @@ -1,33 +1,69 @@ #ifndef __LUNAIX_SIGNAL_H #define __LUNAIX_SIGNAL_H -#include +#include +#include -#define _SIG_NUM 8 +#define _SIG_NUM 16 #define _SIG_PENDING(bitmap, sig) ((bitmap) & (1 << (sig))) -#define _SIGSEGV 0 -#define _SIGALRM 1 -#define _SIGCHLD 2 -#define _SIGCLD _SIGCHLD -#define _SIGINT 3 -#define _SIGKILL 4 -#define _SIGSTOP 5 -#define _SIGCONT 6 +#define _SIGSEGV SIGSEGV +#define _SIGALRM SIGALRM +#define _SIGCHLD SIGCHLD +#define _SIGCLD SIGCLD +#define _SIGINT SIGINT +#define _SIGKILL SIGKILL +#define _SIGSTOP SIGSTOP +#define _SIGCONT SIGCONT +#define _SIGTERM SIGTERM +#define _SIG_BLOCK SIG_BLOCK +#define _SIG_UNBLOCK SIG_UNBLOCK +#define _SIG_SETMASK SIG_SETMASK -#define __SIGNAL(num) (1 << (num)) -#define __SET_SIGNAL(bitmap, num) (bitmap = bitmap | __SIGNAL(num)) +#define sigset(num) (1 << (num)) +#define sigset_add(set, num) (set = set | sigset(num)) +#define sigset_test(set, num) (set & sigset(num)) +#define sigset_clear(set, num) ((set) = (set) & ~sigset(num)) +#define sigset_union(set, set2) ((set) = (set) | (set2)) +#define sigset_intersect(set, set2) ((set) = (set) & (set2)) -#define _SIGNAL_UNMASKABLE (__SIGNAL(_SIGKILL) | __SIGNAL(_SIGSTOP)) +struct sigact +{ + sigset_t sa_mask; + void* sa_actor; + void* sa_handler; + pid_t sender; +}; -#define _SIG_BLOCK 1 -#define _SIG_UNBLOCK 2 -#define _SIG_SETMASK 3 +struct sigregistry { + struct sigact* signals[_SIG_NUM]; +}; -typedef unsigned int sigset_t; -typedef void (*sighandler_t)(int); +struct sigctx +{ + sigset_t sig_pending; + sigset_t sig_mask; + signum_t sig_active; + signum_t sig_order[_SIG_NUM]; +}; -__LXSYSCALL2(int, signal, int, signum, sighandler_t, handler); +int +signal_send(pid_t pid, signum_t signum); + +void +signal_dup_context(struct sigctx* dest_ctx); + +void +signal_dup_registry(struct sigregistry* dest_reg); + +void +signal_reset_context(struct sigctx* sigctx); + +void +signal_reset_registry(struct sigregistry* sigreg); + +void +signal_free_registry(struct sigregistry* sigreg); #endif /* __LUNAIX_SIGNAL_H */