Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASMi386_SIGNAL_H |
| 2 | #define _ASMi386_SIGNAL_H |
| 3 | |
| 4 | #include <linux/types.h> |
| 5 | #include <linux/linkage.h> |
| 6 | #include <linux/time.h> |
| 7 | #include <linux/compiler.h> |
| 8 | |
| 9 | /* Avoid too many header ordering problems. */ |
| 10 | struct siginfo; |
| 11 | |
| 12 | #ifdef __KERNEL__ |
| 13 | /* Most things should be clean enough to redefine this at will, if care |
| 14 | is taken to make libc match. */ |
| 15 | |
| 16 | #define _NSIG 64 |
| 17 | #define _NSIG_BPW 32 |
| 18 | #define _NSIG_WORDS (_NSIG / _NSIG_BPW) |
| 19 | |
| 20 | typedef unsigned long old_sigset_t; /* at least 32 bits */ |
| 21 | |
| 22 | typedef struct { |
| 23 | unsigned long sig[_NSIG_WORDS]; |
| 24 | } sigset_t; |
| 25 | |
| 26 | #else |
| 27 | /* Here we must cater to libcs that poke about in kernel headers. */ |
| 28 | |
| 29 | #define NSIG 32 |
| 30 | typedef unsigned long sigset_t; |
| 31 | |
| 32 | #endif /* __KERNEL__ */ |
| 33 | |
| 34 | #define SIGHUP 1 |
| 35 | #define SIGINT 2 |
| 36 | #define SIGQUIT 3 |
| 37 | #define SIGILL 4 |
| 38 | #define SIGTRAP 5 |
| 39 | #define SIGABRT 6 |
| 40 | #define SIGIOT 6 |
| 41 | #define SIGBUS 7 |
| 42 | #define SIGFPE 8 |
| 43 | #define SIGKILL 9 |
| 44 | #define SIGUSR1 10 |
| 45 | #define SIGSEGV 11 |
| 46 | #define SIGUSR2 12 |
| 47 | #define SIGPIPE 13 |
| 48 | #define SIGALRM 14 |
| 49 | #define SIGTERM 15 |
| 50 | #define SIGSTKFLT 16 |
| 51 | #define SIGCHLD 17 |
| 52 | #define SIGCONT 18 |
| 53 | #define SIGSTOP 19 |
| 54 | #define SIGTSTP 20 |
| 55 | #define SIGTTIN 21 |
| 56 | #define SIGTTOU 22 |
| 57 | #define SIGURG 23 |
| 58 | #define SIGXCPU 24 |
| 59 | #define SIGXFSZ 25 |
| 60 | #define SIGVTALRM 26 |
| 61 | #define SIGPROF 27 |
| 62 | #define SIGWINCH 28 |
| 63 | #define SIGIO 29 |
| 64 | #define SIGPOLL SIGIO |
| 65 | /* |
| 66 | #define SIGLOST 29 |
| 67 | */ |
| 68 | #define SIGPWR 30 |
| 69 | #define SIGSYS 31 |
| 70 | #define SIGUNUSED 31 |
| 71 | |
| 72 | /* These should not be considered constants from userland. */ |
| 73 | #define SIGRTMIN 32 |
| 74 | #define SIGRTMAX _NSIG |
| 75 | |
| 76 | /* |
| 77 | * SA_FLAGS values: |
| 78 | * |
| 79 | * SA_ONSTACK indicates that a registered stack_t will be used. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | * SA_RESTART flag to get restarting signals (which were the default long ago) |
| 81 | * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. |
| 82 | * SA_RESETHAND clears the handler when the signal is delivered. |
| 83 | * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. |
| 84 | * SA_NODEFER prevents the current signal from being masked in the handler. |
| 85 | * |
| 86 | * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single |
| 87 | * Unix names RESETHAND and NODEFER respectively. |
| 88 | */ |
| 89 | #define SA_NOCLDSTOP 0x00000001u |
| 90 | #define SA_NOCLDWAIT 0x00000002u |
| 91 | #define SA_SIGINFO 0x00000004u |
| 92 | #define SA_ONSTACK 0x08000000u |
| 93 | #define SA_RESTART 0x10000000u |
| 94 | #define SA_NODEFER 0x40000000u |
| 95 | #define SA_RESETHAND 0x80000000u |
| 96 | |
| 97 | #define SA_NOMASK SA_NODEFER |
| 98 | #define SA_ONESHOT SA_RESETHAND |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | #define SA_RESTORER 0x04000000 |
| 101 | |
| 102 | /* |
| 103 | * sigaltstack controls |
| 104 | */ |
| 105 | #define SS_ONSTACK 1 |
| 106 | #define SS_DISABLE 2 |
| 107 | |
| 108 | #define MINSIGSTKSZ 2048 |
| 109 | #define SIGSTKSZ 8192 |
| 110 | |
Al Viro | b1ecb4c | 2005-05-04 05:40:12 +0100 | [diff] [blame] | 111 | #include <asm-generic/signal.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | #ifdef __KERNEL__ |
| 114 | struct old_sigaction { |
| 115 | __sighandler_t sa_handler; |
| 116 | old_sigset_t sa_mask; |
| 117 | unsigned long sa_flags; |
| 118 | __sigrestore_t sa_restorer; |
| 119 | }; |
| 120 | |
| 121 | struct sigaction { |
| 122 | __sighandler_t sa_handler; |
| 123 | unsigned long sa_flags; |
| 124 | __sigrestore_t sa_restorer; |
| 125 | sigset_t sa_mask; /* mask last for extensibility */ |
| 126 | }; |
| 127 | |
| 128 | struct k_sigaction { |
| 129 | struct sigaction sa; |
| 130 | }; |
| 131 | #else |
| 132 | /* Here we must cater to libcs that poke about in kernel headers. */ |
| 133 | |
| 134 | struct sigaction { |
| 135 | union { |
| 136 | __sighandler_t _sa_handler; |
| 137 | void (*_sa_sigaction)(int, struct siginfo *, void *); |
| 138 | } _u; |
| 139 | sigset_t sa_mask; |
| 140 | unsigned long sa_flags; |
| 141 | void (*sa_restorer)(void); |
| 142 | }; |
| 143 | |
| 144 | #define sa_handler _u._sa_handler |
| 145 | #define sa_sigaction _u._sa_sigaction |
| 146 | |
| 147 | #endif /* __KERNEL__ */ |
| 148 | |
| 149 | typedef struct sigaltstack { |
| 150 | void __user *ss_sp; |
| 151 | int ss_flags; |
| 152 | size_t ss_size; |
| 153 | } stack_t; |
| 154 | |
| 155 | #ifdef __KERNEL__ |
| 156 | #include <asm/sigcontext.h> |
| 157 | |
| 158 | #define __HAVE_ARCH_SIG_BITOPS |
| 159 | |
Constantine Gavrilov | b7fd1ed | 2005-11-17 11:40:43 +0200 | [diff] [blame] | 160 | #define sigaddset(set,sig) \ |
| 161 | (__builtin_constant_p(sig) ? \ |
| 162 | __const_sigaddset((set),(sig)) : \ |
| 163 | __gen_sigaddset((set),(sig))) |
| 164 | |
| 165 | static __inline__ void __gen_sigaddset(sigset_t *set, int _sig) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | { |
Constantine Gavrilov | b7fd1ed | 2005-11-17 11:40:43 +0200 | [diff] [blame] | 167 | __asm__("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Constantine Gavrilov | b7fd1ed | 2005-11-17 11:40:43 +0200 | [diff] [blame] | 170 | static __inline__ void __const_sigaddset(sigset_t *set, int _sig) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | { |
Constantine Gavrilov | b7fd1ed | 2005-11-17 11:40:43 +0200 | [diff] [blame] | 172 | unsigned long sig = _sig - 1; |
| 173 | set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); |
| 174 | } |
| 175 | |
| 176 | #define sigdelset(set,sig) \ |
| 177 | (__builtin_constant_p(sig) ? \ |
| 178 | __const_sigdelset((set),(sig)) : \ |
| 179 | __gen_sigdelset((set),(sig))) |
| 180 | |
| 181 | |
| 182 | static __inline__ void __gen_sigdelset(sigset_t *set, int _sig) |
| 183 | { |
| 184 | __asm__("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); |
| 185 | } |
| 186 | |
Linus Torvalds | cd02e27 | 2005-11-17 10:04:31 -0800 | [diff] [blame] | 187 | static __inline__ void __const_sigdelset(sigset_t *set, int _sig) |
Constantine Gavrilov | b7fd1ed | 2005-11-17 11:40:43 +0200 | [diff] [blame] | 188 | { |
| 189 | unsigned long sig = _sig - 1; |
| 190 | set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static __inline__ int __const_sigismember(sigset_t *set, int _sig) |
| 194 | { |
| 195 | unsigned long sig = _sig - 1; |
| 196 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); |
| 197 | } |
| 198 | |
| 199 | static __inline__ int __gen_sigismember(sigset_t *set, int _sig) |
| 200 | { |
| 201 | int ret; |
| 202 | __asm__("btl %2,%1\n\tsbbl %0,%0" |
| 203 | : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); |
| 204 | return ret; |
| 205 | } |
| 206 | |
| 207 | #define sigismember(set,sig) \ |
| 208 | (__builtin_constant_p(sig) ? \ |
| 209 | __const_sigismember((set),(sig)) : \ |
| 210 | __gen_sigismember((set),(sig))) |
| 211 | |
| 212 | static __inline__ int sigfindinword(unsigned long word) |
| 213 | { |
| 214 | __asm__("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc"); |
| 215 | return word; |
| 216 | } |
| 217 | |
| 218 | struct pt_regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
| 220 | #define ptrace_signal_deliver(regs, cookie) \ |
| 221 | do { \ |
| 222 | if (current->ptrace & PT_DTRACE) { \ |
| 223 | current->ptrace &= ~PT_DTRACE; \ |
| 224 | (regs)->eflags &= ~TF_MASK; \ |
| 225 | } \ |
| 226 | } while (0) |
| 227 | |
| 228 | #endif /* __KERNEL__ */ |
| 229 | |
| 230 | #endif |