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 #ifdef _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
34 __extern const char * const sys_siglist[];
36 /* This assumes sigset_t is either an unsigned long or an array of such,
37 and that _NSIG_BPW in the kernel is always LONG_BIT */
39 static __inline__ int sigemptyset(sigset_t *__set)
41 memset(__set, 0, sizeof *__set);
44 static __inline__ int sigfillset(sigset_t *__set)
46 memset(__set, ~0, sizeof *__set);
49 static __inline__ int sigaddset(sigset_t *__set, int __signum)
51 unsigned long *__lset = (unsigned long *)__set;
52 __lset[__signum/LONG_BIT] |= 1UL << (__signum%LONG_BIT);
55 static __inline__ int sigdelset(sigset_t *__set, int __signum)
57 unsigned long *__lset = (unsigned long *)__set;
58 __lset[__signum/LONG_BIT] &= ~(1UL << (__signum%LONG_BIT));
61 static __inline__ int sigismember(sigset_t *__set, int __signum)
63 unsigned long *__lset = (unsigned long *)__set;
64 return (int)((__lset[__signum/LONG_BIT] >> (__signum%LONG_BIT)) & 1);
67 __extern __sighandler_t __signal(int, __sighandler_t, int);
68 __extern __sighandler_t sysv_signal(int, __sighandler_t);
69 __extern __sighandler_t bsd_signal(int, __sighandler_t);
70 __extern int sigaction(int, const struct sigaction *, struct sigaction *);
71 __extern int sigprocmask(int, const sigset_t *, sigset_t *);
72 __extern int sigpending(sigset_t *);
73 __extern int sigsuspend(const sigset_t *);
74 __extern int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t);
75 __extern int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
76 __extern int rt_sigpending(sigset_t *, size_t);
77 __extern int rt_sigsuspend(const sigset_t *, size_t);
78 __extern int raise(int);
79 __extern int kill(pid_t, int);
81 #endif /* _SIGNAL_H */