netlib.narod.ru< Назад | Оглавление | Далее >

include/linux/signal.h

17123 #ifndef _LINUX_SIGNAL_H
17124 #define _LINUX_SIGNAL_H
17125 
17126 #include <asm/signal.h>
17127 #include <asm/siginfo.h>
17128 
17129 #ifdef __KERNEL__
17130 /* Real Time signals may be queued. */
17131 
 Комментарий
17132 struct signal_queue
17133 {
17134   struct signal_queue *next;
17135   siginfo_t info;
17136 };
17137 
17138 /* Define some primitives to manipulate sigset_t. */
17139 
17140 #ifndef __HAVE_ARCH_SIG_BITOPS
17141 #include <asm/bitops.h>
17142 
17143 /* We don't use <asm/bitops.h> for these because there is
17144  * no need to be atomic.  */
 Комментарий
17145 extern inline void sigaddset(sigset_t *set, int _sig)
17146 {
17147   unsigned long sig = _sig - 1;
17148   if (_NSIG_WORDS == 1)
17149     set->sig[0] |= 1UL << sig;
17150   else
17151     set->sig[sig/_NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
17152 }
17153 
 Комментарий
17154 extern inline void sigdelset(sigset_t *set, int _sig)
17155 {
17156   unsigned long sig = _sig - 1;
17157   if (_NSIG_WORDS == 1)
17158     set->sig[0] &= ~(1UL << sig);
17159   else
17160     set->sig[sig/_NSIG_BPW] &= ~(1UL << (sig%_NSIG_BPW));
17161 }
17162 
 Комментарий
17163 extern inline int sigismember(sigset_t *set, int _sig)
17164 {
17165   unsigned long sig = _sig - 1;
17166   if (_NSIG_WORDS == 1)
17167    return 1 & (set->sig[0] >> sig);
17168   else
17169    return 1 & (set->sig[sig/_NSIG_BPW]>>(sig%_NSIG_BPW));
17170 }
17171 
 Комментарий
17172 extern inline int sigfindinword(unsigned long word)
17173 {
17174   return ffz(~word);
17175 }
17176 
 Комментарий
17177 #define sigmask(sig)    (1UL << ((sig) - 1))
17178 
17179 #endif /* __HAVE_ARCH_SIG_BITOPS */
17180 
17181 #ifndef __HAVE_ARCH_SIG_SETOPS
17182 #include <linux/string.h>
17183 
 Комментарий
17184 #define _SIG_SET_BINOP(name, op)                        \
17185 extern inline void name(sigset_t *r, const sigset_t *a, \
17186                         const sigset_t *b)              \
17187 {                                                       \
17188   unsigned long a0, a1, a2, a3, b0, b1, b2, b3;         \
17189   unsigned long i;                                      \
17190                                                         \
17191   for (i = 0; i < _NSIG_WORDS/4; ++i) {                 \
17192     a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1];             \
17193     a2 = a->sig[4*i+2]; a3 = a->sig[4*i+3];             \
17194     b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1];             \
17195     b2 = b->sig[4*i+2]; b3 = b->sig[4*i+3];             \
17196     r->sig[4*i+0] = op(a0, b0);                         \
17197     r->sig[4*i+1] = op(a1, b1);                         \
17198     r->sig[4*i+2] = op(a2, b2);                         \
17199     r->sig[4*i+3] = op(a3, b3);                         \
17200   }                                                     \
17201   switch (_NSIG_WORDS % 4) {                            \
17202       case 3:                                           \
17203     a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1];             \
17204     a2 = a->sig[4*i+2];                                 \
17205     b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1];             \
17206     b2 = b->sig[4*i+2];                                 \
17207     r->sig[4*i+0] = op(a0, b0);                         \
17208     r->sig[4*i+1] = op(a1, b1);                         \
17209     r->sig[4*i+2] = op(a2, b2);                         \
17210     break;                                              \
17211       case 2:                                           \
17212     a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1];             \
17213     b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1];             \
17214     r->sig[4*i+0] = op(a0, b0);                         \
17215     r->sig[4*i+1] = op(a1, b1);                         \
17216     break;                                              \
17217       case 1:                                           \
17218     a0 = a->sig[4*i+0]; b0 = b->sig[4*i+0];             \
17219     r->sig[4*i+0] = op(a0, b0);                         \
17220     break;                                              \
17221   }
17222 }
17223 
17224 #define _sig_or(x,y)    ((x) | (y))
17225 _SIG_SET_BINOP(sigorsets, _sig_or)
17226 
17227 #define _sig_and(x,y)   ((x) & (y))
17228 _SIG_SET_BINOP(sigandsets, _sig_and)
17229 
17230 #define _sig_nand(x,y)  ((x) & ~(y))
17231 _SIG_SET_BINOP(signandsets, _sig_nand)
17232 
17233 #undef _SIG_SET_BINOP
17234 #undef _sig_or
17235 #undef _sig_and
17236 #undef _sig_nand
17237 
 Комментарий
17238 #define _SIG_SET_OP(name, op)                           \
17239 extern inline void name(sigset_t *set)                  \
17240 {                                                       \
17241   unsigned long i;                                      \
17242                                                         \
17243   for (i = 0; i < _NSIG_WORDS/4; ++i) {                 \
17244     set->sig[4*i+0] = op(set->sig[4*i+0]);              \
17245     set->sig[4*i+1] = op(set->sig[4*i+1]);              \
17246     set->sig[4*i+2] = op(set->sig[4*i+2]);              \
17247     set->sig[4*i+3] = op(set->sig[4*i+3]);              \
17248   }                                                     \
17249   switch (_NSIG_WORDS % 4) {                            \
17250       case 3: set->sig[4*i+2] = op(set->sig[4*i+2]);    \
17251       case 2: set->sig[4*i+1] = op(set->sig[4*i+1]);    \
17252       case 1: set->sig[4*i+0] = op(set->sig[4*i+0]);    \
17253   }
17254 }
17255 
17256 #define _sig_not(x)     (~(x))
17257 _SIG_SET_OP(signotset, _sig_not)
17258 
17259 #undef _SIG_SET_OP
17260 #undef _sig_not
17261 
 Комментарий
17262 extern inline void sigemptyset(sigset_t *set)
17263 {
17264   switch (_NSIG_WORDS) {
17265   default:
17266     memset(set, 0, sizeof(sigset_t));
17267     break;
17268   case 2: set->sig[1] = 0;
17269   case 1: set->sig[0] = 0;
17270     break;
17271   }
17272 }
17273 
17274 extern inline void sigfillset(sigset_t *set)
17275 {
17276   switch (_NSIG_WORDS) {
17277   default:
17278     memset(set, -1, sizeof(sigset_t));
17279     break;
17280   case 2: set->sig[1] = -1;
17281   case 1: set->sig[0] = -1;
17282     break;
17283   }
17284 }
17285 
17286 extern char * render_sigset_t(sigset_t *set,
17287                               char *buffer);
17288 
17289 /* Some extensions for manipulating the low 32 signals in
17290    particular.  */
17291 
 Комментарий
17292 extern inline void sigaddsetmask(sigset_t *set,
17293                                  unsigned long mask)
17294 {
17295   set->sig[0] |= mask;
17296 }
17297 
17298 extern inline void sigdelsetmask(sigset_t *set,
17299                                  unsigned long mask)
17300 {
17301   set->sig[0] &= ~mask;
17302 }
17303 
17304 extern inline int sigtestsetmask(sigset_t *set,
17305                                  unsigned long mask)
17306 {
17307   return (set->sig[0] & mask) != 0;
17308 }
17309 
 Комментарий
17310 extern inline void siginitset(sigset_t *set,
17311                               unsigned long mask)
17312 {
17313   set->sig[0] = mask;
17314   switch (_NSIG_WORDS) {
17315   default:
17316     memset(&set->sig[1], 0,sizeof(long)*(_NSIG_WORDS-1));
17317     break;
17318   case 2: set->sig[1] = 0;
17319   case 1:
17320   }
17321 }
17322 
17323 extern inline void siginitsetinv(sigset_t *set,
17324                                  unsigned long mask)
17325 {
17326   set->sig[0] = ~mask;
17327   switch (_NSIG_WORDS) {
17328   default:
17329     memset(&set->sig[1],-1,sizeof(long)*(_NSIG_WORDS-1));
17330     break;
17331   case 2: set->sig[1] = -1;
17332   case 1:
17333   }
17334 }
17335 
17336 #endif /* __HAVE_ARCH_SIG_SETOPS */
17337 
17338 #endif /* __KERNEL__ */
17339 
17340 #endif /* _LINUX_SIGNAL_H */

netlib.narod.ru< Назад | Оглавление | Далее >

Сайт управляется системой uCoz