chiark / gitweb /
[PATCH] volume-id build fix and update
[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 #include <klibc/archsignal.h>
15
16 /* glibc seems to use sig_atomic_t as "int" pretty much on all architectures.
17    Do the same, but allow the architecture to override. */
18 #ifdef _KLIBC_HAS_ARCH_SIG_ATOMIC_T
19 typedef int sig_atomic_t;
20 #endif
21
22 /* Some architectures don't define these */
23 #ifndef SA_RESETHAND
24 # define SA_RESETHAND SA_ONESHOT
25 #endif
26 #ifndef SA_NODEFER
27 # define SA_NODEFER SA_NOMASK
28 #endif
29 #ifndef NSIG
30 # define NSIG _NSIG
31 #endif
32
33 __extern const char * const sys_siglist[];
34
35 /* This assumes sigset_t is either an unsigned long or an array of such,
36    and that _NSIG_BPW in the kernel is always LONG_BIT */
37
38 static __inline__ int sigemptyset(sigset_t *__set)
39 {
40   memset(__set, 0, sizeof *__set);
41   return 0;
42 }
43 static __inline__ int sigfillset(sigset_t *__set)
44 {
45   memset(__set, ~0, sizeof *__set);
46   return 0;
47 }
48 static __inline__ int sigaddset(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 sigdelset(sigset_t *__set, int __signum)
55 {
56   unsigned long *__lset = (unsigned long *)__set;
57   __lset[__signum/LONG_BIT] &= ~(1UL << (__signum%LONG_BIT));
58   return 0;
59 }
60 static __inline__ int sigismember(sigset_t *__set, int __signum)
61 {
62   unsigned long *__lset = (unsigned long *)__set;
63   return (int)((__lset[__signum/LONG_BIT] >> (__signum%LONG_BIT)) & 1);
64 }
65
66 __extern __sighandler_t __signal(int, __sighandler_t, int);
67 __extern __sighandler_t sysv_signal(int, __sighandler_t);
68 __extern __sighandler_t bsd_signal(int, __sighandler_t);
69 __extern int sigaction(int, const struct sigaction *, struct sigaction *);
70 __extern int sigprocmask(int, const sigset_t *, sigset_t *);
71 __extern int sigpending(sigset_t *);
72 __extern int sigsuspend(const sigset_t *);
73 __extern int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t);
74 __extern int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
75 __extern int rt_sigpending(sigset_t *, size_t);
76 __extern int rt_sigsuspend(const sigset_t *, size_t);
77 __extern int raise(int);
78 __extern int kill(pid_t, int);
79
80 #endif /* _SIGNAL_H */