aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/timeout.c4
-rw-r--r--src/util/timeout.h16
2 files changed, 16 insertions, 4 deletions
diff --git a/src/util/timeout.c b/src/util/timeout.c
index 21f9591..6fdbf16 100644
--- a/src/util/timeout.c
+++ b/src/util/timeout.c
@@ -5,7 +5,7 @@
#include "timeout.h"
#include "util/memory.h"
-__thread jmp_buf timeout_ptr;
+__thread sigjmp_buf timeout_ptr;
__thread bool timeout_in = false;
__thread timer_t *timeout_timer;
__thread struct sigevent *sevp;
@@ -45,4 +45,4 @@ bool timeout_init() {
void timeout_quit() {
// deinit the main thread.
timeout_thread_quit();
-} \ No newline at end of file
+}
diff --git a/src/util/timeout.h b/src/util/timeout.h
index 5a5c0d2..57e3d22 100644
--- a/src/util/timeout.h
+++ b/src/util/timeout.h
@@ -15,6 +15,19 @@
#include "io/output.h"
#include "misc/config.h"
+#ifdef __APPLE__
+
+#include <posix-macos-timer.h>
+#define SIGEV_THREAD_ID 0
+#define SIGEV_UN_TID_SYS_GETTID
+
+#else
+
+#define SIGEV_UN_TID_SYS_GETTID \
+ sevp->_sigev_un._tid = (__pid_t)syscall(SYS_gettid);
+
+#endif
+
extern __thread sigjmp_buf timeout_ptr;
extern __thread bool timeout_in;
extern __thread timer_t *timeout_timer;
@@ -35,8 +48,7 @@ extern __thread struct sigevent *sevp;
sevp->sigev_notify = SIGEV_THREAD_ID; \
sevp->sigev_signo = SIGALRM; \
sevp->sigev_value.sival_int = 0; \
- sevp->_sigev_un._tid = (__pid_t)syscall(SYS_gettid); \
- \
+ SIGEV_UN_TID_SYS_GETTID \
timer_create(CLOCK_MONOTONIC, sevp, timeout_timer); \
struct itimerspec timer_time = { \
.it_interval = {.tv_sec = 0, .tv_nsec = 0}, \