bos-mrafs-support-20010212
[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
21 #define AFS_SIGSET_CLEAR()
22 #define AFS_SIGSET_RESTORE()
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 #define AFS_SIGSET_CLEAR() \
31 do { \
32          sigfillset(&i_tset); \
33          assert(AFS_SET_SIGMASK(SIG_BLOCK, &i_tset, &i_oset) == 0); \
34 } while (0)
35
36 #define AFS_SIGSET_RESTORE() \
37 do { \
38          assert(AFS_SET_SIGMASK(SIG_SETMASK, &i_oset, NULL) == 0); \
39 } while (0)
40 #endif /* AFS_NT40_ENV */
41
42 #endif /* AFS_PTHREAD_NOSIGS_H */