Ticket #7242: 0001-Adapt-to-NetBSD-s-struct-kevent.patch

File 0001-Adapt-to-NetBSD-s-struct-kevent.patch, 2.6 KB (added by iquiw, 3 years ago)

Patch to adapt to NetBSD's struct kevent (rebased)

  • GHC/Event/KQueue.hsc

    From afec58460d55c6284da9fb51838280f7ab053b91 Mon Sep 17 00:00:00 2001
    From: Iku Iwasa <[email protected]>
    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 import qualified GHC.Event.Array as A 
    5050#if defined(HAVE_KEVENT64)
    5151import Data.Int (Int64)
    5252import Data.Word (Word64)
     53#elif defined(netbsd_HOST_OS)
     54import Data.Int (Int64)
    5355#endif
    5456
    5557#include <sys/types.h>
    data Event = KEvent { 
    172174    , filter :: {-# UNPACK #-} !Filter
    173175    , flags  :: {-# UNPACK #-} !Flag
    174176    , fflags :: {-# UNPACK #-} !FFlag
     177#ifdef netbsd_HOST_OS
     178    , data_  :: {-# UNPACK #-} !Int64
     179#else
    175180    , data_  :: {-# UNPACK #-} !CIntPtr
     181#endif
    176182    , udata  :: {-# UNPACK #-} !(Ptr ())
    177183    } deriving Show
    178184
    newtype FFlag = FFlag Word32 
    210216 , noteEOF = NOTE_EOF
    211217 }
    212218
     219#if SIZEOF_KEV_FLAGS == 4 /* kevent.flag: uint32_t or uint16_t. */
     220newtype Flag = Flag Word32
     221#else
    213222newtype Flag = Flag Word16
     223#endif
    214224    deriving (Eq, Show, Storable)
    215225
    216226#{enum Flag, Flag
    newtype Flag = Flag Word16 
    218228 , flagDelete  = EV_DELETE
    219229 }
    220230
     231#if SIZEOF_KEV_FILTER == 4 /*kevent.filter: uint32_t or uint16_t. */
     232newtype Filter = Filter Word32
     233#else
    221234newtype Filter = Filter Word16
     235#endif
    222236    deriving (Bits, Eq, Num, Show, Storable)
    223237
    224238#{enum Filter, Filter
  • configure.ac

    diff --git a/configure.ac b/configure.ac
    index 0ce53b7..b679520 100644
    a b fi 
    5151
    5252if test "$ac_cv_header_sys_event_h" = yes -a "$ac_cv_func_kqueue" = yes; then
    5353  AC_DEFINE([HAVE_KQUEUE], [1], [Define if you have kqueue support.])
     54
     55  AC_CHECK_SIZEOF([kev.filter], [], [#include <sys/event.h>
     56struct kevent kev;])
     57
     58  AC_CHECK_SIZEOF([kev.flags], [], [#include <sys/event.h>
     59struct kevent kev;])
    5460fi
    5561
    5662if test "$ac_cv_header_poll_h" = yes -a "$ac_cv_func_poll" = yes; then
  • include/EventConfig.h.in

    diff --git a/include/EventConfig.h.in b/include/EventConfig.h.in
    index 032ceb1..061b6ac 100644
    a b  
    8383
    8484/* Define to 1 if you have the ANSI C header files. */
    8585#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