chiark / gitweb /
[PATCH] klibc specific tweaks
[elogind.git] / klibc / klibc / include / signal.h
1 /*
2  * signal.h
3  */
4
5 #ifndef _SIGNAL_H
6 #define _SIGNAL_H
7
8 #include <klibc/extern.h>
9 #include <string.h>             /* For memset() */
10 #include <limits.h>             /* For LONG_BIT */
11 #include <sys/types.h>
12 #include <asm/signal.h>
13
14 /* Some architectures don't define these */
15 #ifndef SA_RESETHAND
16 # define SA_RESETHAND SA_ONESHOT
17 #endif
18 #ifndef SA_NODEFER
19 # define SA_NODEFER SA_NOMASK
20 #endif
21 #ifndef NSIG
22 # define NSIG _NSIG
23 #endif
24
25 typedef int sig_atomic_t;
26
27 __extern const char * const sys_siglist[];
28
29 /* This assumes sigset_t is either an unsigned long or an array of such,
30    and that _NSIG_BPW in the kernel is always LONG_BIT */
31
32 static __inline__ int sigemptyset(sigset_t *__set)
33 {
34   memset(__set, 0, sizeof *__set);
35   return 0;
36 }
37 static __inline__ int sigfillset(sigset_t *__set)
38 {
39   memset(__set, ~0, sizeof *__set);
40   return 0;
41 }
42 static __inline__ int sigaddset(sigset_t *__set, int __signum)
43 {
44   unsigned long *__lset = (unsigned long *)__set;
45   __lset[__signum/LONG_BIT] |= 1UL << (__signum%LONG_BIT);
46   return 0;
47 }
48 static __inline__ int sigdelset(sigset_t *__set, int __signum)
49 {
50   unsigned long *__lset = (unsigned long *)__set;
51   __lset[__signum/LONG_BIT] &= ~(1UL << (__signum%LONG_BIT));
52   return 0;
53 }
54 static __inline__ int sigismember(sigset_t *__set, int __signum)
55 {
56   unsigned long *__lset = (unsigned long *)__set;
57   return (int)((__lset[__signum/LONG_BIT] >> (__signum%LONG_BIT)) & 1);
58 }
59
60 __extern __sighandler_t __signal(int, __sighandler_t, int);
61 __extern __sighandler_t signal(int, __sighandler_t);
62 __extern __sighandler_t bsd_signal(int, __sighandler_t);
63 __extern int sigaction(int, const struct sigaction *, struct sigaction *);
64 __extern int sigprocmask(int, const sigset_t *, sigset_t *);
65 __extern int sigpending(sigset_t *);
66 __extern int sigsuspend(const sigset_t *);
67 __extern int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t);
68 __extern int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
69 __extern int rt_sigpending(sigset_t *, size_t);
70 __extern int rt_sigsuspend(const sigset_t *, size_t);
71 __extern int raise(int);
72 __extern int kill(pid_t, int);
73
74 #endif /* _SIGNAL_H */