Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adapt to NetBSD's struct kevent

  • Loading branch information...
commit 1bc8270f086ee634e6f399272accc934495ad350 1 parent 219ea0e
@iquiw iquiw authored simonmar committed
Showing with 26 additions and 0 deletions.
  1. +14 −0 GHC/Event/KQueue.hsc
  2. +6 −0 configure.ac
  3. +6 −0 include/EventConfig.h.in
View
14 GHC/Event/KQueue.hsc
@@ -50,6 +50,8 @@ import qualified GHC.Event.Array as A
#if defined(HAVE_KEVENT64)
import Data.Int (Int64)
import Data.Word (Word64)
+#elif defined(netbsd_HOST_OS)
+import Data.Int (Int64)
#endif
#include <sys/types.h>
@@ -172,7 +174,11 @@ data Event = KEvent {
, filter :: {-# UNPACK #-} !Filter
, flags :: {-# UNPACK #-} !Flag
, fflags :: {-# UNPACK #-} !FFlag
+#ifdef netbsd_HOST_OS
+ , data_ :: {-# UNPACK #-} !Int64
+#else
, data_ :: {-# UNPACK #-} !CIntPtr
+#endif
, udata :: {-# UNPACK #-} !(Ptr ())
} deriving Show
@@ -210,7 +216,11 @@ newtype FFlag = FFlag Word32
, noteEOF = NOTE_EOF
}
+#if SIZEOF_KEV_FLAGS == 4 /* kevent.flag: uint32_t or uint16_t. */
+newtype Flag = Flag Word32
+#else
newtype Flag = Flag Word16
+#endif
deriving (Eq, Show, Storable)
#{enum Flag, Flag
@@ -218,7 +228,11 @@ newtype Flag = Flag Word16
, flagDelete = EV_DELETE
}
+#if SIZEOF_KEV_FILTER == 4 /*kevent.filter: uint32_t or uint16_t. */
+newtype Filter = Filter Word32
+#else
newtype Filter = Filter Word16
+#endif
deriving (Bits, Eq, Num, Show, Storable)
#{enum Filter, Filter
View
6 configure.ac
@@ -51,6 +51,12 @@ fi
if test "$ac_cv_header_sys_event_h" = yes -a "$ac_cv_func_kqueue" = yes; then
AC_DEFINE([HAVE_KQUEUE], [1], [Define if you have kqueue support.])
+
+ AC_CHECK_SIZEOF([kev.filter], [], [#include <sys/event.h>
+struct kevent kev;])
+
+ AC_CHECK_SIZEOF([kev.flags], [], [#include <sys/event.h>
+struct kevent kev;])
fi
if test "$ac_cv_header_poll_h" = yes -a "$ac_cv_func_poll" = yes; then
View
6 include/EventConfig.h.in
@@ -83,3 +83,9 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+
+/* The size of `kev.filter', as computed by sizeof. */
+#undef SIZEOF_KEV_FILTER
+
+/* The size of `kev.flags', as computed by sizeof. */
+#undef SIZEOF_KEV_FLAGS
Please sign in to comment.
Something went wrong with that request. Please try again.