[commit: base] : Making KQueue compilable. (60d1dfe)

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


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

On branch  : 

http://hackage.haskell.org/trac/ghc/changeset/60d1dfee590aedf45c728f041b02060219a32d54

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

commit 60d1dfee590aedf45c728f041b02060219a32d54
Author: Kazu Yamamoto <kazu at iij.ad.jp>
Date:   Fri Dec 28 12:25:20 2012 +0900

    Making KQueue compilable.

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

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

diff --git a/GHC/Event/KQueue.hsc b/GHC/Event/KQueue.hsc
index ad32d8e..2c3f99c 100644
--- a/GHC/Event/KQueue.hsc
+++ b/GHC/Event/KQueue.hsc
@@ -108,7 +108,7 @@ toFilter evt
 modifyFdOnce :: EventQueue -> Fd -> E.Event -> IO ()
 modifyFdOnce q fd evt = do
     let !ev = event fd (toFilter evt) (flagAdd .|. flagOneshot) noteEOF
-    kqueueControl (kqueueFd q) ev
+    kqueueControl (eqFd q) ev
 
 poll :: EventQueue
      -> Maybe Timeout
@@ -269,7 +269,7 @@ instance Storable TimeSpec where
 kqueue :: IO QueueFd
 kqueue = QueueFd `fmap` throwErrnoIfMinus1 "kqueue" c_kqueue
 
-kqueueControl :: KQueueFd -> Event -> IO ()
+kqueueControl :: QueueFd -> Event -> IO ()
 kqueueControl kfd ev = void $
     withTimeSpec (TimeSpec 0 0) $ \tp ->
         withEvent ev $ \evp -> kevent False kfd evp 1 nullPtr 0 tp
@@ -290,6 +290,9 @@ kevent safe k chs chlen evs evlen ts
       else c_kevent_unsafe k chs (fromIntegral chlen) evs (fromIntegral evlen) ts
 #endif
 
+withEvent :: Event -> (Ptr Event -> IO a) -> IO a
+withEvent ev f = alloca $ \ptr -> poke ptr ev >> f ptr
+
 withTimeSpec :: TimeSpec -> (Ptr TimeSpec -> IO a) -> IO a
 withTimeSpec ts f =
     if tv_sec ts < 0 then
@@ -322,7 +325,7 @@ foreign import ccall safe "kevent64"
                -> Ptr TimeSpec -> IO CInt
 
 foreign import ccall unsafe "kevent64"
-    c_kevent64_unsafe :: KQueueFd -> Ptr Event -> CInt -> Ptr Event -> CInt -> CUInt
+    c_kevent64_unsafe :: QueueFd -> Ptr Event -> CInt -> Ptr Event -> CInt -> CUInt
                       -> Ptr TimeSpec -> IO CInt               
 #elif defined(HAVE_KEVENT)
 foreign import capi safe "sys/event.h kevent"





More information about the ghc-commits mailing list