From 9084f3862973aa5eccfafe51c6682a6aef123d4d Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 13 May 2020 17:08:54 +0200 Subject: Add utility functions for clearing/setting signal mask Signed-off-by: David Oberhollenzer --- lib/Makemodule.am | 1 + lib/include/util.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 lib/include/util.h (limited to 'lib') diff --git a/lib/Makemodule.am b/lib/Makemodule.am index fa8789b..836bd4d 100644 --- a/lib/Makemodule.am +++ b/lib/Makemodule.am @@ -1,6 +1,7 @@ libinit_a_SOURCES = lib/init/delsvc.c lib/init/svcmap.c lib/init/rdsvc.c libinit_a_SOURCES += lib/init/svcscan.c lib/init/del_svc_list.c libinit_a_SOURCES += lib/init/svc_tsort.c lib/include/service.h +libinit_a_SOURCES += lib/include/util.h libinit_a_CPPFLAGS = $(AM_CPPFLAGS) libinit_a_CFLAGS = $(AM_CFLAGS) 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 + +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 */ -- cgit v1.2.3