death to trailing whitespace
[openafs.git] / src / util / pthread_nosigs.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef AFS_PTHREAD_NOSIGS_H
11 #define AFS_PTHREAD_NOSIGS_H
12
13 /* We want servers to only handle signals in the main thread. To do this
14  * we must block signals in the child threads. To do this, wrap pthread_create
15  * with these macros.
16  */
17
18 #ifdef AFS_NT40_ENV
19 /* Compilers complain about empty declaration unless at end of decl's */
20 #define AFS_SIGSET_DECL int i_junk=0
21 #define AFS_SIGSET_CLEAR() ++i_junk
22 #define AFS_SIGSET_RESTORE() --i_junk
23 #else
24 #define AFS_SIGSET_DECL sigset_t i_tset, i_oset
25 #ifdef AFS_AIX42_ENV
26 #define AFS_SET_SIGMASK sigthreadmask
27 #else
28 #define AFS_SET_SIGMASK pthread_sigmask
29 #endif
30 #ifdef SIGSEGV
31 #define _SETSEGV sigdelset(&i_tset, SIGSEGV);
32 #else
33 #define _SETSEGV ;
34 #endif
35 #ifdef SIGBUS
36 #define _SETBUS sigdelset(&i_tset, SIGBUS);
37 #else
38 #define _SETBUS ;
39 #endif
40 #ifdef SIGILL
41 #define _SETILL sigdelset(&i_tset, SIGILL);
42 #else
43 #define _SETILL ;
44 #endif
45 #ifdef SIGTRAP
46 #define _SETTRAP sigdelset(&i_tset, SIGTRAP);
47 #else
48 #define _SETTRAP ;
49 #endif
50 #ifdef SIGABRT
51 #define _SETABRT sigdelset(&i_tset, SIGABRT);
52 #else
53 #define _SETABRT ;
54 #endif
55 #ifdef SIGFPE
56 #define _SETFPE sigdelset(&i_tset, SIGFPE);
57 #else
58 #define _SETFPE ;
59 #endif
60 #define AFS_SIGSET_CLEAR() \
61 do { \
62          sigfillset(&i_tset); \
63          _SETSEGV \
64          _SETBUS \
65          _SETILL \
66          _SETTRAP \
67          _SETABRT \
68          _SETFPE \
69          assert(AFS_SET_SIGMASK(SIG_BLOCK, &i_tset, &i_oset) == 0); \
70 } while (0)
71
72 #define AFS_SIGSET_RESTORE() \
73 do { \
74          assert(AFS_SET_SIGMASK(SIG_SETMASK, &i_oset, NULL) == 0); \
75 } while (0)
76 #endif /* AFS_NT40_ENV */
77
78 #endif /* AFS_PTHREAD_NOSIGS_H */