diff options
| author | Ján Jančár | 2021-09-23 13:59:42 +0200 |
|---|---|---|
| committer | GitHub | 2021-09-23 13:59:42 +0200 |
| commit | c26a14d988a45dd529e9217339bf27da772c2e3c (patch) | |
| tree | 8974ecc6dc76e8064d8abcc4361c5364e929c3e2 /src | |
| parent | d41953bcbedced945a82d1bc6c30ad690f12eaa9 (diff) | |
| parent | 9d67fed63c6d493eeea99d2fd5bd078c7926da98 (diff) | |
| download | ecgen-c26a14d988a45dd529e9217339bf27da772c2e3c.tar.gz ecgen-c26a14d988a45dd529e9217339bf27da772c2e3c.tar.zst ecgen-c26a14d988a45dd529e9217339bf27da772c2e3c.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/util/timeout.c | 4 | ||||
| -rw-r--r-- | src/util/timeout.h | 16 |
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}, \ |
