From f952444d63d750d9421b9b5d35429231048254ac Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Tue, 30 Aug 2022 02:22:56 -0700 Subject: [PATCH] Add OpenBSD support --- main.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 823401e..b72e11c 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,14 @@ #include #include +#ifdef __OpenBSD__ +#define SIG_MIN SIGUSR1 +#define SIG_MAX 31 +#else +#define SIG_MIN SIGRTMIN +#define SIG_MAX SIGRTMAX +#endif + #ifdef HAS_X11 #include #endif @@ -526,10 +534,10 @@ static void initialize_modules() { if (modules[i].disabled) { continue; } - if (modules[i].signal + SIGRTMIN > SIGRTMAX) { + if (modules[i].signal + SIG_MIN > SIG_MAX) { has_error = TRUE; qtb_log("%s: error: signal out of range: %d\n", - modules[i].signal + SIGRTMIN); + modules[i].signal + SIG_MIN); continue; } if (modules[i].init) { @@ -561,7 +569,7 @@ static void signal_handler(int signum) { clock_gettime(global_cpu_clock_id, ¤t_time); int module_updated = FALSE; unsigned long current_time_ms = timespec_to_miliseconds(¤t_time); - int adjusted_signum = signum - SIGRTMIN; + int adjusted_signum = signum - SIG_MIN; size_t i; for (i = 0; i < global_module_count; ++i) { if (!modules[i].disabled && modules[i].signal == adjusted_signum) { @@ -578,7 +586,7 @@ static void signal_handler(int signum) { static void setup_signals() { sigemptyset(&global_real_time_mask); int i; - for (i = SIGRTMIN; i <= SIGRTMAX; ++i) { + for (i = SIG_MIN; i <= SIG_MAX; ++i) { sigaddset(&global_real_time_mask, i); struct sigaction action; sigemptyset(&action.sa_mask); @@ -788,7 +796,7 @@ void qtb_die() { } void qtb_signal_modules(int sig) { - pthread_kill(global_main_thread, SIGRTMIN + sig); + pthread_kill(global_main_thread, SIG_MIN + sig); } void *qtb_malloc(size_t size) {