[commit: base] master: Use eventfd_write to write to wakeup eventfd in Control. (a37a358)

Johan Tibell johan.tibell at gmail.com
Tue Feb 12 07:50:22 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/a37a358afe770f21fc674852ffc0308ad4da1463

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

commit a37a358afe770f21fc674852ffc0308ad4da1463
Author: Andreas Voellmy <andreas.voellmy at gmail.com>
Date:   Fri Dec 21 16:53:26 2012 -0500

    Use eventfd_write to write to wakeup eventfd in Control.

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

 GHC/Event/Control.hs |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/GHC/Event/Control.hs b/GHC/Event/Control.hs
index d08323d..e1b0aa0 100644
--- a/GHC/Event/Control.hs
+++ b/GHC/Event/Control.hs
@@ -49,6 +49,7 @@ import System.Posix.Types (Fd)
 #if defined(HAVE_EVENTFD)
 import Data.Word (Word64)
 import Foreign.C.Error (throwErrnoIfMinus1)
+import Foreign.C.Types (CULong(..))
 #else
 import Foreign.C.Error (eAGAIN, eWOULDBLOCK, getErrno, throwErrno)
 #endif
@@ -167,10 +168,9 @@ readControlMessage ctrl fd
 
 sendWakeup :: Control -> IO ()
 #if defined(HAVE_EVENTFD)
-sendWakeup c = alloca $ \p -> do
-  poke p (1 :: Word64)
+sendWakeup c =
   throwErrnoIfMinus1_ "sendWakeup" $
-    c_write (fromIntegral (controlEventFd c)) (castPtr p) 8
+  c_eventfd_write (fromIntegral (controlEventFd c)) 1    
 #else
 sendWakeup c = do
   n <- sendMessage (wakeupWriteFd c) CMsgWakeup
@@ -197,6 +197,9 @@ sendMessage fd msg = alloca $ \p -> do
 #if defined(HAVE_EVENTFD)
 foreign import ccall unsafe "sys/eventfd.h eventfd"
    c_eventfd :: CInt -> CInt -> IO CInt
+
+foreign import ccall unsafe "sys/eventfd.h eventfd_write"
+   c_eventfd_write :: CInt -> CULong -> IO CInt                
 #endif
 
 -- Used to tell the RTS how it can send messages to the I/O manager.





More information about the ghc-commits mailing list