diff options
Diffstat (limited to 'lib/include')
-rw-r--r-- | lib/include/util.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/include/util.h b/lib/include/util.h new file mode 100644 index 0000000..884eeab --- /dev/null +++ b/lib/include/util.h @@ -0,0 +1,26 @@ +#ifndef UTIL_H +#define UTIL_H + +#include <signal.h> + +static inline void cli(sigset_t *old_mask) +{ + sigset_t mask; + + sigfillset(&mask); + sigprocmask(SIG_SETMASK, &mask, old_mask); +} + +static inline void sti(const sigset_t *old_mask) +{ + sigset_t mask; + + if (old_mask == NULL) { + sigemptyset(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); + } else { + sigprocmask(SIG_SETMASK, old_mask, NULL); + } +} + +#endif /* UTIL_H */ |