Add OpenBSD support

This commit is contained in:
Alexander Rosenberg 2022-08-30 02:22:56 -07:00
parent 3810e65cb5
commit f952444d63
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

18
main.c
View File

@ -10,6 +10,14 @@
#include <time.h>
#include <unistd.h>
#ifdef __OpenBSD__
#define SIG_MIN SIGUSR1
#define SIG_MAX 31
#else
#define SIG_MIN SIGRTMIN
#define SIG_MAX SIGRTMAX
#endif
#ifdef HAS_X11
#include <X11/Xlib.h>
#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, &current_time);
int module_updated = FALSE;
unsigned long current_time_ms = timespec_to_miliseconds(&current_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) {