From eed0697ec9cf39da42c22dbd94d9addadd841fb0 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 14 Feb 2024 15:31:56 +0100 Subject: [PATCH] os: consolidate busfault handling The symbols HAVE_SIGACTION and BUSFAULT are set under the same conditions, so can be consolidated into one. Also define dummies when HAVE_SIGACTION is not set, so a few #ifdef's less clutterig the code. Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- hw/xquartz/quartzStartup.c | 2 +- include/busfault.h | 7 ++++++- include/meson.build | 2 -- os/WaitFor.c | 2 -- os/meson.build | 2 +- os/osinit.c | 2 -- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c index 732eba983..77ff84506 100644 --- a/hw/xquartz/quartzStartup.c +++ b/hw/xquartz/quartzStartup.c @@ -99,7 +99,7 @@ QuartzInitServer(int argc, char **argv, char **envp) sigset_t set; sigemptyset(&set); sigaddset(&set, SIGALRM); -#ifdef BUSFAULT +#ifdef HAVE_SIGACTION sigaddset(&set, SIGBUS); #endif pthread_sigmask(SIG_BLOCK, &set, NULL); diff --git a/include/busfault.h b/include/busfault.h index 3b668818d..f89a5833e 100644 --- a/include/busfault.h +++ b/include/busfault.h @@ -25,7 +25,7 @@ #include -#ifdef BUSFAULT +#ifdef HAVE_SIGACTION #include @@ -43,6 +43,11 @@ busfault_check(void); Bool busfault_init(void); +#else + +static inline void busfault_check(void) {} +static inline Bool busfault_init(void) { return FALSE; } + #endif #endif /* _BUSFAULT_H_ */ diff --git a/include/meson.build b/include/meson.build index 6ec1a96f8..c109bcc40 100644 --- a/include/meson.build +++ b/include/meson.build @@ -179,8 +179,6 @@ conf_data.set('HAVE_VSNPRINTF', cc.has_function('vsnprintf') ? '1' : false) conf_data.set('HAVE_WALKCONTEXT', cc.has_function('walkcontext') ? '1' : false) conf_data.set('HAVE_XUCRED_CR_PID', cc.has_member('struct xucred', 'cr_pid', prefix : '#include ') ? '1' : false) -conf_data.set('BUSFAULT', conf_data.get('HAVE_SIGACTION')) - # Don't let X dependencies typedef 'pointer' conf_data.set('_XTYPEDEF_POINTER', '1') conf_data.set('_XITYPEDEF_POINTER', '1') diff --git a/os/WaitFor.c b/os/WaitFor.c index 1bb4ecc45..f34964f2e 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -180,9 +180,7 @@ WaitForSomething(Bool are_ready) were_ready = FALSE; -#ifdef BUSFAULT busfault_check(); -#endif /* We need a while loop here to handle crashed connections and the screen saver timeout */ diff --git a/os/meson.build b/os/meson.build index 85b445f20..a6cf8a444 100644 --- a/os/meson.build +++ b/os/meson.build @@ -46,7 +46,7 @@ if conf_data.get('HAVE_POLL').to_int() == 0 srcs_os += 'xserver_poll.c' endif -if conf_data.get('BUSFAULT').to_int() != 0 +if conf_data.get('HAVE_SIGACTION').to_int() != 0 srcs_os += 'busfault.c' endif diff --git a/os/osinit.c b/os/osinit.c index 8575319ff..db8427ba9 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -199,9 +199,7 @@ OsInit(void) } } #endif /* !WIN32 || __CYGWIN__ */ -#ifdef BUSFAULT busfault_init(); -#endif server_poll = ospoll_create(); if (!server_poll) FatalError("failed to allocate poll structure");