[commit: ghc] master: rts: A bit of cleanup of posix itimer implementation (76e110f)

git at git.haskell.org git at git.haskell.org
Wed Jun 20 15:51:56 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/76e110fb3219f4e4b3d3fdef42f0027cbd13d49c/ghc

>---------------------------------------------------------------

commit 76e110fb3219f4e4b3d3fdef42f0027cbd13d49c
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Tue Jun 19 23:18:12 2018 -0400

    rts: A bit of cleanup of posix itimer implementation
    
    * Use bool instead of HsBool
    * Use barf instead of sysErrorBelch; stg_exit
    
    Test Plan: Validate
    
    Reviewers: erikd, simonmar
    
    Subscribers: rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4874


>---------------------------------------------------------------

76e110fb3219f4e4b3d3fdef42f0027cbd13d49c
 rts/posix/itimer/Pthread.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/rts/posix/itimer/Pthread.c b/rts/posix/itimer/Pthread.c
index c45d57e..f591d5e 100644
--- a/rts/posix/itimer/Pthread.c
+++ b/rts/posix/itimer/Pthread.c
@@ -84,11 +84,11 @@ static Time itimer_interval = DEFAULT_TICK_INTERVAL;
 
 // Should we be firing ticks?
 // Writers to this must hold the mutex below.
-static volatile HsBool stopped = 0;
+static volatile bool stopped = false;
 
 // should the ticker thread exit?
 // This can be set without holding the mutex.
-static volatile HsBool exited = 1;
+static volatile bool exited = true;
 
 // Signaled when we want to (re)start the timer
 static Condition start_cond;
@@ -109,15 +109,13 @@ static void *itimer_thread_func(void *_handle_tick)
 
     timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
     if (timerfd == -1) {
-        sysErrorBelch("timerfd_create");
-        stg_exit(EXIT_FAILURE);
+        barf("timerfd_create");
     }
     if (!TFD_CLOEXEC) {
-      fcntl(timerfd, F_SETFD, FD_CLOEXEC);
+        fcntl(timerfd, F_SETFD, FD_CLOEXEC);
     }
     if (timerfd_settime(timerfd, 0, &it, NULL)) {
-        sysErrorBelch("timerfd_settime");
-        stg_exit(EXIT_FAILURE);
+        barf("timerfd_settime");
     }
 #endif
 
@@ -158,8 +156,8 @@ void
 initTicker (Time interval, TickProc handle_tick)
 {
     itimer_interval = interval;
-    stopped = 0;
-    exited = 0;
+    stopped = false;
+    exited = false;
 
     initCondition(&start_cond);
     initMutex(&mutex);
@@ -173,8 +171,7 @@ initTicker (Time interval, TickProc handle_tick)
         pthread_setname_np(thread, "ghc_ticker");
 #endif
     } else {
-        sysErrorBelch("Itimer: Failed to spawn thread");
-        stg_exit(EXIT_FAILURE);
+        barf("Itimer: Failed to spawn thread");
     }
 }
 
@@ -201,7 +198,7 @@ void
 exitTicker (bool wait)
 {
     ASSERT(!exited);
-    exited = 1;
+    exited = true;
     // ensure that ticker wakes up if stopped
     startTicker();
 



More information about the ghc-commits mailing list