From a5dfcf7009d44ebf23484297bfa8828f60f71233 Mon Sep 17 00:00:00 2001
From: Iku Iwasa <iku.iwasa@gmail.com>
Date: Sun, 16 Sep 2012 16:36:25 +0900
Subject: [PATCH 1/2] Adapt to NetBSD's struct kevent
---
GHC/Event/KQueue.hsc | 14 ++++++++++++++
configure.ac | 6 ++++++
include/EventConfig.h.in | 6 ++++++
3 files changed, 26 insertions(+)
diff --git a/GHC/Event/KQueue.hsc b/GHC/Event/KQueue.hsc
index 68aade3..230785a 100644
|
a
|
b
|
|
| 50 | 50 | #if defined(HAVE_KEVENT64) |
| 51 | 51 | import Data.Int (Int64) |
| 52 | 52 | import Data.Word (Word64) |
| | 53 | #elif defined(netbsd_HOST_OS) |
| | 54 | import Data.Int (Int64) |
| 53 | 55 | #endif |
| 54 | 56 | |
| 55 | 57 | #include <sys/types.h> |
| … |
… |
|
| 172 | 174 | , filter :: {-# UNPACK #-} !Filter |
| 173 | 175 | , flags :: {-# UNPACK #-} !Flag |
| 174 | 176 | , fflags :: {-# UNPACK #-} !FFlag |
| | 177 | #ifdef netbsd_HOST_OS |
| | 178 | , data_ :: {-# UNPACK #-} !Int64 |
| | 179 | #else |
| 175 | 180 | , data_ :: {-# UNPACK #-} !CIntPtr |
| | 181 | #endif |
| 176 | 182 | , udata :: {-# UNPACK #-} !(Ptr ()) |
| 177 | 183 | } deriving Show |
| 178 | 184 | |
| … |
… |
|
| 210 | 216 | , noteEOF = NOTE_EOF |
| 211 | 217 | } |
| 212 | 218 | |
| | 219 | #if SIZEOF_KEV_FLAGS == 4 /* kevent.flag: uint32_t or uint16_t. */ |
| | 220 | newtype Flag = Flag Word32 |
| | 221 | #else |
| 213 | 222 | newtype Flag = Flag Word16 |
| | 223 | #endif |
| 214 | 224 | deriving (Eq, Show, Storable) |
| 215 | 225 | |
| 216 | 226 | #{enum Flag, Flag |
| … |
… |
|
| 218 | 228 | , flagDelete = EV_DELETE |
| 219 | 229 | } |
| 220 | 230 | |
| | 231 | #if SIZEOF_KEV_FILTER == 4 /*kevent.filter: uint32_t or uint16_t. */ |
| | 232 | newtype Filter = Filter Word32 |
| | 233 | #else |
| 221 | 234 | newtype Filter = Filter Word16 |
| | 235 | #endif |
| 222 | 236 | deriving (Bits, Eq, Num, Show, Storable) |
| 223 | 237 | |
| 224 | 238 | #{enum Filter, Filter |
diff --git a/configure.ac b/configure.ac
index 0ce53b7..b679520 100644
|
a
|
b
|
|
| 51 | 51 | |
| 52 | 52 | if test "$ac_cv_header_sys_event_h" = yes -a "$ac_cv_func_kqueue" = yes; then |
| 53 | 53 | AC_DEFINE([HAVE_KQUEUE], [1], [Define if you have kqueue support.]) |
| | 54 | |
| | 55 | AC_CHECK_SIZEOF([kev.filter], [], [#include <sys/event.h> |
| | 56 | struct kevent kev;]) |
| | 57 | |
| | 58 | AC_CHECK_SIZEOF([kev.flags], [], [#include <sys/event.h> |
| | 59 | struct kevent kev;]) |
| 54 | 60 | fi |
| 55 | 61 | |
| 56 | 62 | if test "$ac_cv_header_poll_h" = yes -a "$ac_cv_func_poll" = yes; then |
diff --git a/include/EventConfig.h.in b/include/EventConfig.h.in
index 032ceb1..061b6ac 100644
|
a
|
b
|
|
| 83 | 83 | |
| 84 | 84 | /* Define to 1 if you have the ANSI C header files. */ |
| 85 | 85 | #undef STDC_HEADERS |
| | 86 | |
| | 87 | /* The size of `kev.filter', as computed by sizeof. */ |
| | 88 | #undef SIZEOF_KEV_FILTER |
| | 89 | |
| | 90 | /* The size of `kev.flags', as computed by sizeof. */ |
| | 91 | #undef SIZEOF_KEV_FLAGS |