Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66159 - trunk/boost/asio/detail/impl
From: chris_at_[hidden]
Date: 2010-10-24 03:58:27


Author: chris_kohlhoff
Date: 2010-10-24 03:58:23 EDT (Sun, 24 Oct 2010)
New Revision: 66159
URL: http://svn.boost.org/trac/boost/changeset/66159

Log:
Fix kqueue_reactor so that it compiles on NetBSD. Refs #4662.

Text files modified:
   trunk/boost/asio/detail/impl/kqueue_reactor.ipp | 31 +++++++++++++++++++++++--------
   1 files changed, 23 insertions(+), 8 deletions(-)

Modified: trunk/boost/asio/detail/impl/kqueue_reactor.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/kqueue_reactor.ipp (original)
+++ trunk/boost/asio/detail/impl/kqueue_reactor.ipp 2010-10-24 03:58:23 EDT (Sun, 24 Oct 2010)
@@ -26,6 +26,15 @@
 
 #include <boost/asio/detail/push_options.hpp>
 
+#if defined(__NetBSD__)
+# define BOOST_ASIO_KQUEUE_EV_SET(ev, ident, filt, flags, fflags, data, udata) \
+ EV_SET(ev, ident, filt, flags, fflags, \
+ data, reinterpret_cast<intptr_t>(udata))
+#else
+# define BOOST_ASIO_KQUEUE_EV_SET(ev, ident, filt, flags, fflags, data, udata) \
+ EV_SET(ev, ident, filt, flags, fflags, data, udata)
+#endif
+
 namespace boost {
 namespace asio {
 namespace detail {
@@ -129,17 +138,17 @@
     switch (op_type)
     {
     case read_op:
- EV_SET(&event, descriptor, EVFILT_READ,
+ BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_READ,
           EV_ADD | EV_ONESHOT, 0, 0, descriptor_data);
       break;
     case write_op:
- EV_SET(&event, descriptor, EVFILT_WRITE,
+ BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_WRITE,
           EV_ADD | EV_ONESHOT, 0, 0, descriptor_data);
       break;
     case except_op:
       if (!descriptor_data->op_queue_[read_op].empty())
         return; // Already registered for read events.
- EV_SET(&event, descriptor, EVFILT_READ,
+ BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_READ,
           EV_ADD | EV_ONESHOT, EV_OOBAND, 0, descriptor_data);
       break;
     }
@@ -234,7 +243,7 @@
   for (int i = 0; i < num_events; ++i)
   {
     int descriptor = events[i].ident;
- void* ptr = events[i].udata;
+ void* ptr = reinterpret_cast<void*>(events[i].udata);
     if (ptr == &interrupter_)
     {
       // No need to reset the interrupter since we're leaving the descriptor
@@ -247,7 +256,11 @@
 
       // Exception operations must be processed first to ensure that any
       // out-of-band data is read before normal data.
+#if defined(__NetBSD__)
+ static const unsigned int filter[max_ops] =
+#else
       static const int filter[max_ops] =
+#endif
         { EVFILT_READ, EVFILT_WRITE, EVFILT_READ };
       for (int j = max_ops - 1; j >= 0; --j)
       {
@@ -282,16 +295,16 @@
       {
       case EVFILT_READ:
         if (!descriptor_data->op_queue_[read_op].empty())
- EV_SET(&event, descriptor, EVFILT_READ,
+ BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_READ,
               EV_ADD | EV_ONESHOT, 0, 0, descriptor_data);
         else if (!descriptor_data->op_queue_[except_op].empty())
- EV_SET(&event, descriptor, EVFILT_READ,
+ BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_READ,
               EV_ADD | EV_ONESHOT, EV_OOBAND, 0, descriptor_data);
         else
           continue;
       case EVFILT_WRITE:
         if (!descriptor_data->op_queue_[write_op].empty())
- EV_SET(&event, descriptor, EVFILT_WRITE,
+ BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_WRITE,
               EV_ADD | EV_ONESHOT, 0, 0, descriptor_data);
         else
           continue;
@@ -322,7 +335,7 @@
 void kqueue_reactor::interrupt()
 {
   struct kevent event;
- EV_SET(&event, interrupter_.read_descriptor(),
+ BOOST_ASIO_KQUEUE_EV_SET(&event, interrupter_.read_descriptor(),
       EVFILT_READ, EV_ADD | EV_ONESHOT, 0, 0, &interrupter_);
   ::kevent(kqueue_fd_, &event, 1, 0, 0, 0);
 }
@@ -365,6 +378,8 @@
 } // namespace asio
 } // namespace boost
 
+#undef BOOST_ASIO_KQUEUE_EV_SET
+
 #include <boost/asio/detail/pop_options.hpp>
 
 #endif // defined(BOOST_ASIO_HAS_KQUEUE)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk