8 #include <klibc/compiler.h>
9 #include <klibc/extern.h>
10 #include <string.h> /* For memset() */
11 #include <limits.h> /* For LONG_BIT */
12 #include <sys/types.h>
13 #include <asm/signal.h>
15 #include <klibc/archsignal.h>
17 /* glibc seems to use sig_atomic_t as "int" pretty much on all architectures.
18 Do the same, but allow the architecture to override. */
19 #ifndef _KLIBC_HAS_ARCH_SIG_ATOMIC_T
20 typedef int sig_atomic_t;
23 /* Some architectures don't define these */
25 # define SA_RESETHAND SA_ONESHOT
28 # define SA_NODEFER SA_NOMASK
30 /* Some architectures define NSIG and not _NSIG or vice versa */
38 /* If we don't have any real-time signals available to userspace,
40 #if SIGRTMAX <= SIGRTMIN
45 __extern const char * const sys_siglist[];
47 /* This assumes sigset_t is either an unsigned long or an array of such,
48 and that _NSIG_BPW in the kernel is always LONG_BIT */
50 static __inline__ int sigemptyset(sigset_t *__set)
52 memset(__set, 0, sizeof *__set);
55 static __inline__ int sigfillset(sigset_t *__set)
57 memset(__set, ~0, sizeof *__set);
60 static __inline__ int sigaddset(sigset_t *__set, int __signum)
62 unsigned long *__lset = (unsigned long *)__set;
63 __lset[__signum/LONG_BIT] |= 1UL << (__signum%LONG_BIT);
66 static __inline__ int sigdelset(sigset_t *__set, int __signum)
68 unsigned long *__lset = (unsigned long *)__set;
69 __lset[__signum/LONG_BIT] &= ~(1UL << (__signum%LONG_BIT));
72 static __inline__ int sigismember(sigset_t *__set, int __signum)
74 unsigned long *__lset = (unsigned long *)__set;
75 return (int)((__lset[__signum/LONG_BIT] >> (__signum%LONG_BIT)) & 1);
78 __extern __sighandler_t __signal(int, __sighandler_t, int);
79 __extern __sighandler_t sysv_signal(int, __sighandler_t);
80 __extern __sighandler_t bsd_signal(int, __sighandler_t);
81 __extern int sigaction(int, const struct sigaction *, struct sigaction *);
82 __extern int sigprocmask(int, const sigset_t *, sigset_t *);
83 __extern int sigpending(sigset_t *);
84 __extern int sigsuspend(const sigset_t *);
85 __extern int raise(int);
86 __extern int kill(pid_t, int);
88 #endif /* _SIGNAL_H */