summaryrefslogtreecommitdiff
path: root/rts/posix/Ticker.c
diff options
context:
space:
mode:
Diffstat (limited to 'rts/posix/Ticker.c')
-rw-r--r--rts/posix/Ticker.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/rts/posix/Ticker.c b/rts/posix/Ticker.c
index 35387cdff4..4adefdf9aa 100644
--- a/rts/posix/Ticker.c
+++ b/rts/posix/Ticker.c
@@ -65,13 +65,17 @@
* On Linux we can use timerfd_* (introduced in Linux
* 2.6.25) and a thread instead of alarm signals. It avoids the risk of
* interrupting syscalls (see #10840) and the risk of being accidentally
- * modified in user code using signals.
+ * modified in user code using signals. NetBSD has also added timerfd
+ * support since version 10.
+ *
+ * For older version of linux/netbsd without timerfd we fall back to the
+ * pthread based implementation.
*/
-#if defined(linux_HOST_OS) && HAVE_SYS_TIMERFD_H
-#define USE_PTHREAD_FOR_ITIMER
+#if HAVE_SYS_TIMERFD_H
+#define USE_TIMERFD_FOR_ITIMER
#endif
-#if defined(freebsd_HOST_OS)
+#if defined(linux_HOST_OS)
#define USE_PTHREAD_FOR_ITIMER
#endif
@@ -79,6 +83,10 @@
#define USE_PTHREAD_FOR_ITIMER
#endif
+#if defined(freebsd_HOST_OS)
+#define USE_PTHREAD_FOR_ITIMER
+#endif
+
#if defined(solaris2_HOST_OS)
/* USE_TIMER_CREATE is usually disabled for Solaris. In fact it is
supported well on this OS, but requires additional privilege. When
@@ -98,7 +106,9 @@ ghc-stage2: timer_create: Not owner
#endif /* solaris2_HOST_OS */
// Select the variant to use
-#if defined(USE_PTHREAD_FOR_ITIMER)
+#if defined(USE_TIMERFD_FOR_ITIMER)
+#include "ticker/TimerFd.c"
+#elif defined(USE_PTHREAD_FOR_ITIMER)
#include "ticker/Pthread.c"
#elif defined(USE_TIMER_CREATE)
#include "ticker/TimerCreate.c"