backport to buster
[hcoop/debian/openafs.git] / src / util / pthread_nosigs.h
CommitLineData
805e021f
CE
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() \
61do { \
62 int b; \
63 sigfillset(&i_tset); \
64 _SETSEGV \
65 _SETBUS \
66 _SETILL \
67 _SETTRAP \
68 _SETABRT \
69 _SETFPE \
70 b = (AFS_SET_SIGMASK(SIG_BLOCK, &i_tset, &i_oset) == 0); \
71 opr_Assert(b); \
72} while (0)
73
74#define AFS_SIGSET_RESTORE() \
75do { \
76 int b = (AFS_SET_SIGMASK(SIG_SETMASK, &i_oset, NULL) == 0); \
77 opr_Assert(b); \
78} while (0)
79#endif /* AFS_NT40_ENV */
80
81#endif /* AFS_PTHREAD_NOSIGS_H */