Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | #ifndef _LINUX_SIGNAL_H #define _LINUX_SIGNAL_H #include <asm/signal.h> #include <asm/siginfo.h> #ifdef __KERNEL__ /* * Real Time signals may be queued. */ struct signal_queue { struct signal_queue *next; siginfo_t info; }; /* * Define some primitives to manipulate sigset_t. */ #ifndef __HAVE_ARCH_SIG_BITOPS #include <asm/bitops.h> /* We don't use <asm/bitops.h> for these because there is no need to be atomic. */ extern inline void sigaddset(sigset_t *set, int _sig) { unsigned long sig = _sig - 1; if (_NSIG_WORDS == 1) set->sig[0] |= 1UL << sig; else set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW); } extern inline void sigdelset(sigset_t *set, int _sig) { unsigned long sig = _sig - 1; if (_NSIG_WORDS == 1) set->sig[0] &= ~(1UL << sig); else set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW)); } extern inline int sigismember(sigset_t *set, int _sig) { unsigned long sig = _sig - 1; if (_NSIG_WORDS == 1) return 1 & (set->sig[0] >> sig); else return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); } extern inline int sigfindinword(unsigned long word) { return ffz(~word); } #define sigmask(sig) (1UL << ((sig) - 1)) #endif /* __HAVE_ARCH_SIG_BITOPS */ #ifndef __HAVE_ARCH_SIG_SETOPS #include <linux/string.h> #define _SIG_SET_BINOP(name, op) \ extern inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \ { \ unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \ unsigned long i; \ \ for (i = 0; i < _NSIG_WORDS/4; ++i) { \ a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1]; \ a2 = a->sig[4*i+2]; a3 = a->sig[4*i+3]; \ b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1]; \ b2 = b->sig[4*i+2]; b3 = b->sig[4*i+3]; \ r->sig[4*i+0] = op(a0, b0); \ r->sig[4*i+1] = op(a1, b1); \ r->sig[4*i+2] = op(a2, b2); \ r->sig[4*i+3] = op(a3, b3); \ } \ switch (_NSIG_WORDS % 4) { \ case 3: \ a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1]; a2 = a->sig[4*i+2]; \ b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1]; b2 = b->sig[4*i+2]; \ r->sig[4*i+0] = op(a0, b0); \ r->sig[4*i+1] = op(a1, b1); \ r->sig[4*i+2] = op(a2, b2); \ break; \ case 2: \ a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1]; \ b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1]; \ r->sig[4*i+0] = op(a0, b0); \ r->sig[4*i+1] = op(a1, b1); \ break; \ case 1: \ a0 = a->sig[4*i+0]; b0 = b->sig[4*i+0]; \ r->sig[4*i+0] = op(a0, b0); \ break; \ } \ } #define _sig_or(x,y) ((x) | (y)) _SIG_SET_BINOP(sigorsets, _sig_or) #define _sig_and(x,y) ((x) & (y)) _SIG_SET_BINOP(sigandsets, _sig_and) #define _sig_nand(x,y) ((x) & ~(y)) _SIG_SET_BINOP(signandsets, _sig_nand) #undef _SIG_SET_BINOP #undef _sig_or #undef _sig_and #undef _sig_nand #define _SIG_SET_OP(name, op) \ extern inline void name(sigset_t *set) \ { \ unsigned long i; \ \ for (i = 0; i < _NSIG_WORDS/4; ++i) { \ set->sig[4*i+0] = op(set->sig[4*i+0]); \ set->sig[4*i+1] = op(set->sig[4*i+1]); \ set->sig[4*i+2] = op(set->sig[4*i+2]); \ set->sig[4*i+3] = op(set->sig[4*i+3]); \ } \ switch (_NSIG_WORDS % 4) { \ case 3: set->sig[4*i+2] = op(set->sig[4*i+2]); \ case 2: set->sig[4*i+1] = op(set->sig[4*i+1]); \ case 1: set->sig[4*i+0] = op(set->sig[4*i+0]); \ } \ } #define _sig_not(x) (~(x)) _SIG_SET_OP(signotset, _sig_not) #undef _SIG_SET_OP #undef _sig_not extern inline void sigemptyset(sigset_t *set) { switch (_NSIG_WORDS) { default: memset(set, 0, sizeof(sigset_t)); break; case 2: set->sig[1] = 0; case 1: set->sig[0] = 0; break; } } extern inline void sigfillset(sigset_t *set) { switch (_NSIG_WORDS) { default: memset(set, -1, sizeof(sigset_t)); break; case 2: set->sig[1] = -1; case 1: set->sig[0] = -1; break; } } extern char * render_sigset_t(sigset_t *set, char *buffer); /* Some extensions for manipulating the low 32 signals in particular. */ extern inline void sigaddsetmask(sigset_t *set, unsigned long mask) { set->sig[0] |= mask; } extern inline void sigdelsetmask(sigset_t *set, unsigned long mask) { set->sig[0] &= ~mask; } extern inline int sigtestsetmask(sigset_t *set, unsigned long mask) { return (set->sig[0] & mask) != 0; } extern inline void siginitset(sigset_t *set, unsigned long mask) { set->sig[0] = mask; switch (_NSIG_WORDS) { default: memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1)); break; case 2: set->sig[1] = 0; case 1: } } extern inline void siginitsetinv(sigset_t *set, unsigned long mask) { set->sig[0] = ~mask; switch (_NSIG_WORDS) { default: memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1)); break; case 2: set->sig[1] = -1; case 1: } } #endif /* __HAVE_ARCH_SIG_SETOPS */ #endif /* __KERNEL__ */ #endif /* _LINUX_SIGNAL_H */ |