Skip to content
Browse files

Added conditional compilation of backends

  • Loading branch information...
1 parent 8e80a19 commit 9c3a2880effb340465456a50e26902e1997019a5 @tibbe tibbe committed Jul 17, 2009
Showing with 21 additions and 4 deletions.
  1. +12 −2 event.cabal
  2. +9 −2 src/System/Event.hs
View
14 event.cabal
@@ -20,7 +20,6 @@ library
other-modules:
System.Event.Array
System.Event.Internal
- System.Event.KQueue
System.Event.Vector
build-depends:
@@ -29,7 +28,18 @@ library
ghc-prim,
unix
- extensions: CPP, ForeignFunctionInterface, MagicHash, UnboxedTuples
+ if os(darwin)
+ other-modules:
+ System.Event.KQueue
+ cpp-options: -DBACKEND_KQUEUE
+
+ extensions:
+ CPP,
+ ExistentialQuantification,
+ ForeignFunctionInterface,
+ MagicHash,
+ UnboxedTuples
+
ghc-options: -Wall -funbox-strict-fields
if impl(ghc >= 6.8)
ghc-options: -fwarn-tabs
View
11 src/System/Event.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE ExistentialQuantification, ForeignFunctionInterface #-}
+{-# LANGUAGE CPP, ExistentialQuantification, ForeignFunctionInterface #-}
module System.Event
( -- * Types
@@ -22,9 +22,14 @@ import Foreign.C.Types (CInt)
import System.Event.Internal (Backend, Event(..))
import qualified System.Event.Internal as I
-import qualified System.Event.KQueue as KQueue
import qualified System.Event.Vector as V
+#ifdef BACKEND_KQUEUE
+import qualified System.Event.KQueue as KQueue
+#else
+# error not implemented for this operating system
+#endif
+
------------------------------------------------------------------------
-- Types
@@ -42,7 +47,9 @@ data EventLoop = forall a. Backend a => EventLoop
-- | Create a new event loop.
new :: IO EventLoop
new = do
+#ifdef BACKEND_KQUEUE
be <- KQueue.new -- TODO: Detect backend to use.
+#endif
cbs <- stToIO $ V.empty
return $ EventLoop be cbs

0 comments on commit 9c3a288

Please sign in to comment.
Something went wrong with that request. Please try again.