26
26
27
27
#include " asio/detail/push_options.hpp"
28
28
29
+ #if defined(__NetBSD__)
30
+ # define ASIO_KQUEUE_EV_SET (ev, ident, filt, flags, fflags, data, udata ) \
31
+ EV_SET (ev, ident, filt, flags, fflags, \
32
+ data, reinterpret_cast <intptr_t >(udata))
33
+ #else
34
+ # define ASIO_KQUEUE_EV_SET (ev, ident, filt, flags, fflags, data, udata ) \
35
+ EV_SET (ev, ident, filt, flags, fflags, data, udata)
36
+ #endif
37
+
29
38
namespace asio {
30
39
namespace detail {
31
40
@@ -128,17 +137,17 @@ void kqueue_reactor::start_op(int op_type, socket_type descriptor,
128
137
switch (op_type)
129
138
{
130
139
case read_op:
131
- EV_SET (&event, descriptor, EVFILT_READ,
140
+ ASIO_KQUEUE_EV_SET (&event, descriptor, EVFILT_READ,
132
141
EV_ADD | EV_ONESHOT, 0 , 0 , descriptor_data);
133
142
break ;
134
143
case write_op:
135
- EV_SET (&event, descriptor, EVFILT_WRITE,
144
+ ASIO_KQUEUE_EV_SET (&event, descriptor, EVFILT_WRITE,
136
145
EV_ADD | EV_ONESHOT, 0 , 0 , descriptor_data);
137
146
break ;
138
147
case except_op:
139
148
if (!descriptor_data->op_queue_ [read_op].empty ())
140
149
return ; // Already registered for read events.
141
- EV_SET (&event, descriptor, EVFILT_READ,
150
+ ASIO_KQUEUE_EV_SET (&event, descriptor, EVFILT_READ,
142
151
EV_ADD | EV_ONESHOT, EV_OOBAND, 0 , descriptor_data);
143
152
break ;
144
153
}
@@ -233,7 +242,7 @@ void kqueue_reactor::run(bool block, op_queue<operation>& ops)
233
242
for (int i = 0 ; i < num_events; ++i)
234
243
{
235
244
int descriptor = events[i].ident ;
236
- void * ptr = events[i].udata ;
245
+ void * ptr = reinterpret_cast < void *>( events[i].udata ) ;
237
246
if (ptr == &interrupter_)
238
247
{
239
248
// No need to reset the interrupter since we're leaving the descriptor
@@ -246,7 +255,11 @@ void kqueue_reactor::run(bool block, op_queue<operation>& ops)
246
255
247
256
// Exception operations must be processed first to ensure that any
248
257
// out-of-band data is read before normal data.
258
+ #if defined(__NetBSD__)
259
+ static const unsigned int filter[max_ops] =
260
+ #else
249
261
static const int filter[max_ops] =
262
+ #endif
250
263
{ EVFILT_READ, EVFILT_WRITE, EVFILT_READ };
251
264
for (int j = max_ops - 1 ; j >= 0 ; --j)
252
265
{
@@ -281,16 +294,16 @@ void kqueue_reactor::run(bool block, op_queue<operation>& ops)
281
294
{
282
295
case EVFILT_READ:
283
296
if (!descriptor_data->op_queue_ [read_op].empty ())
284
- EV_SET (&event, descriptor, EVFILT_READ,
297
+ ASIO_KQUEUE_EV_SET (&event, descriptor, EVFILT_READ,
285
298
EV_ADD | EV_ONESHOT, 0 , 0 , descriptor_data);
286
299
else if (!descriptor_data->op_queue_ [except_op].empty ())
287
- EV_SET (&event, descriptor, EVFILT_READ,
300
+ ASIO_KQUEUE_EV_SET (&event, descriptor, EVFILT_READ,
288
301
EV_ADD | EV_ONESHOT, EV_OOBAND, 0 , descriptor_data);
289
302
else
290
303
continue ;
291
304
case EVFILT_WRITE:
292
305
if (!descriptor_data->op_queue_ [write_op].empty ())
293
- EV_SET (&event, descriptor, EVFILT_WRITE,
306
+ ASIO_KQUEUE_EV_SET (&event, descriptor, EVFILT_WRITE,
294
307
EV_ADD | EV_ONESHOT, 0 , 0 , descriptor_data);
295
308
else
296
309
continue ;
@@ -321,7 +334,7 @@ void kqueue_reactor::run(bool block, op_queue<operation>& ops)
321
334
void kqueue_reactor::interrupt ()
322
335
{
323
336
struct kevent event;
324
- EV_SET (&event, interrupter_.read_descriptor (),
337
+ ASIO_KQUEUE_EV_SET (&event, interrupter_.read_descriptor (),
325
338
EVFILT_READ, EV_ADD | EV_ONESHOT, 0 , 0 , &interrupter_);
326
339
::kevent (kqueue_fd_, &event, 1 , 0 , 0 , 0 );
327
340
}
@@ -363,6 +376,8 @@ timespec* kqueue_reactor::get_timeout(timespec& ts)
363
376
} // namespace detail
364
377
} // namespace asio
365
378
379
+ #undef ASIO_KQUEUE_EV_SET
380
+
366
381
#include " asio/detail/pop_options.hpp"
367
382
368
383
#endif // defined(ASIO_HAS_KQUEUE)
0 commit comments