summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2021-07-12 16:14:38 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-27 04:48:26 -0400
commit8c5c27f11ea2832fd2870551f4bff22a8faaa87a (patch)
tree2792acab27e7d4bcff6de8b4e4f4451b30673cd3
parent63184a71277aa15608659ad20f45b7b0fe9746bc (diff)
downloadhaskell-8c5c27f11ea2832fd2870551f4bff22a8faaa87a.tar.gz
Rename itimer to ticker in rts/posix for consistency.
-rw-r--r--rts/posix/OSMem.c2
-rw-r--r--rts/posix/Ticker.c (renamed from rts/posix/Itimer.c)32
-rw-r--r--rts/posix/ticker/Pthread.c (renamed from rts/posix/itimer/Pthread.c)8
-rw-r--r--rts/posix/ticker/Setitimer.c (renamed from rts/posix/itimer/Setitimer.c)0
-rw-r--r--rts/posix/ticker/TimerCreate.c (renamed from rts/posix/itimer/TimerCreate.c)0
-rw-r--r--rts/rts.cabal.in7
6 files changed, 26 insertions, 23 deletions
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index 30d9981f16..f27e5ee0d2 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -588,7 +588,7 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len)
/* Make sure we leave enough vmem for at least three threads.
This number was found through trial and error. We're at least launching
- that many threads (e.g., itimer). We can't know for sure how much we need,
+ that many threads (e.g., itimer/ticker). We can't know for sure how much we need,
but at least we can fail early and give a useful error message in this case. */
if (((W_) (asLimit.rlim_cur - *len )) < ((W_) (stacksz * 3))) {
// Three stacks is 1/3 of needed, then convert to Megabyte
diff --git a/rts/posix/Itimer.c b/rts/posix/Ticker.c
index eba45cc72e..23308b6808 100644
--- a/rts/posix/Itimer.c
+++ b/rts/posix/Ticker.c
@@ -15,6 +15,9 @@
*
* Hence, we often use the old-fashioned @setitimer@ that just about everyone
* seems to support. So much for standards.
+ *
+ * If you are looking for Itimer.c then this is the right file. I renamed it
+ * Ticker.c for consistency.
*/
#include "PosixSource.h"
@@ -46,20 +49,15 @@
#include "Rts.h"
/*
- * timer_create doesn't exist and setitimer doesn't fire on iOS, so we're using
- * a pthreads-based implementation. It may be to do with interference with the
- * signals of the debugger. Revisit. See #7723.
- */
-#if defined(ios_HOST_OS)
-#define USE_PTHREAD_FOR_ITIMER
-#endif
-
-/*
- * We want to avoid using the SIGALRM signals whenever possible as these signals
- * interrupt system calls (see #10840) and can be overridden by user code. On
- * Darwin we can use a dedicated thread and usleep.
+ * It used to be that timer_create doesn't exist on iOS and setitimer doesn't fire on iOS
+ * during debugging. See #7723. Seems to be an issue with signals.
+ *
+ * We also want to avoid using alarm signals, as these can interrupt system calls (#10840)
+ * or can be overwritten by user code.
+ *
+ * So we are using the pthread based implementation.
*/
-#if defined(darwin_HOST_OS)
+#if defined(ios_HOST_OS) || defined(darwin_HOST_OS)
#define USE_PTHREAD_FOR_ITIMER
#endif
@@ -101,9 +99,11 @@ ghc-stage2: timer_create: Not owner
// Select the variant to use
#if defined(USE_PTHREAD_FOR_ITIMER)
-#include "itimer/Pthread.c"
+#include "ticker/Pthread.c"
#elif defined(USE_TIMER_CREATE)
-#include "itimer/TimerCreate.c"
+ //#error TimerCreate
+#include "ticker/TimerCreate.c"
#else
-#include "itimer/Setitimer.c"
+ //#error Setitimer
+#include "ticker/Setitimer.c"
#endif
diff --git a/rts/posix/itimer/Pthread.c b/rts/posix/ticker/Pthread.c
index 84501acb6f..3cc7b2b801 100644
--- a/rts/posix/itimer/Pthread.c
+++ b/rts/posix/ticker/Pthread.c
@@ -138,11 +138,11 @@ static void *itimer_thread_func(void *_handle_tick)
IF_DEBUG(scheduler, debugBelch("read(timerfd) returned 0 with errno=0. This is a known kernel bug. We just ignore it."));
}
else if (r != sizeof(nticks) && errno != EINTR) {
- barf("Itimer: read(timerfd) failed with %s and returned %zd", strerror(errno), r);
+ barf("Ticker: read(timerfd) failed with %s and returned %zd", strerror(errno), r);
}
} else {
if (rtsSleep(itimer_interval) != 0) {
- sysErrorBelch("ITimer: sleep failed: %s", strerror(errno));
+ sysErrorBelch("Ticker: sleep failed: %s", strerror(errno));
}
}
@@ -216,7 +216,7 @@ initTicker (Time interval, TickProc handle_tick)
pthread_setname_np(thread, "%s", "ghc_ticker");
#endif
} else {
- barf("Itimer: Failed to spawn thread: %s", strerror(errno));
+ barf("Ticker: Failed to spawn thread: %s", strerror(errno));
}
}
@@ -250,7 +250,7 @@ exitTicker (bool wait)
// wait for ticker to terminate if necessary
if (wait) {
if (pthread_join(thread, NULL)) {
- sysErrorBelch("Itimer: Failed to join: %s", strerror(errno));
+ sysErrorBelch("Ticker: Failed to join: %s", strerror(errno));
}
closeMutex(&mutex);
closeCondition(&start_cond);
diff --git a/rts/posix/itimer/Setitimer.c b/rts/posix/ticker/Setitimer.c
index 1221a72a83..1221a72a83 100644
--- a/rts/posix/itimer/Setitimer.c
+++ b/rts/posix/ticker/Setitimer.c
diff --git a/rts/posix/itimer/TimerCreate.c b/rts/posix/ticker/TimerCreate.c
index 43081d8a30..43081d8a30 100644
--- a/rts/posix/itimer/TimerCreate.c
+++ b/rts/posix/ticker/TimerCreate.c
diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in
index c46873e205..3ceae1cbdc 100644
--- a/rts/rts.cabal.in
+++ b/rts/rts.cabal.in
@@ -586,13 +586,16 @@ library
else
c-sources: posix/GetEnv.c
posix/GetTime.c
- posix/Itimer.c
+ posix/Ticker.c
posix/OSMem.c
posix/OSThreads.c
posix/Select.c
posix/Signals.c
posix/TTY.c
- -- posix/*.c -- we do not want itimer
+ -- ticker/*.c
+ -- We don't want to compile posix/ticker/*.c, these will be #included
+ -- from Ticker.c
+
-- Note [fd_set_overflow]
-- ~~~~~~~~~~~~~~~~~~~~~~