1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*  Monkey HTTP Server
4  *  ==================
5  *  Copyright 2001-2017 Eduardo Silva <eduardo@monkey.io>
6  *
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  */
19 
20 
21 #ifndef MK_EVENT_KQUEUE_H
22 #define MK_EVENT_KQUEUE_H
23 
24 #ifndef __linux__
25    #include <sys/types.h>
26    #include <sys/event.h>
27    #include <sys/time.h>
28 #endif
29 
30 #ifdef LINUX_KQUEUE
31    #include <kqueue/sys/event.h>
32 
33    /* Not defined */
34    #ifndef NOTE_SECONDS
35       #define NOTE_SECONDS 0x00000001
36    #endif
37 #endif
38 
39 struct mk_event_ctx {
40     int kfd;
41     int queue_size;
42     struct kevent *events;
43 };
44 
45 static inline int filter_mask(int16_t f)
46 {
47     if (f == EVFILT_READ) {
48         return MK_EVENT_READ;
49     }
50 
51     if (f == EVFILT_WRITE) {
52         return MK_EVENT_WRITE;
53     }
54 
55     return 0;
56 }
57 
58 
59 #define mk_event_foreach(event, evl)                                           \
60     int __i;                                                                   \
61     struct mk_event_ctx *__ctx = evl->data;                                    \
localTracksGUI_InfoDialog::Private62                                                                                \
63     if (evl->n_events > 0) {                                                   \
64         event = __ctx->events[0].udata;                                        \
65     }                                                                          \
__anon32189f300102(const auto& track) 66                                                                                \
67     for (__i = 0;                                                              \
68          __i < evl->n_events;                                                  \
69          __i++,                                                                \
70              event = ((__i < evl->n_events) ? __ctx->events[__i].udata : NULL) \
71          )
72 #endif
73