]>
git.saurik.com Git - apple/libdispatch.git/blob - src/event/event_config.h
2 * Copyright (c) 2016 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
21 #ifndef __DISPATCH_EVENT_EVENT_CONFIG__
22 #define __DISPATCH_EVENT_EVENT_CONFIG__
24 #if defined(__linux__)
25 # include <sys/eventfd.h>
26 # define DISPATCH_EVENT_BACKEND_EPOLL 1
27 # define DISPATCH_EVENT_BACKEND_KEVENT 0
28 #elif __has_include(<sys/event.h>)
29 # include <sys/event.h>
30 # define DISPATCH_EVENT_BACKEND_EPOLL 0
31 # define DISPATCH_EVENT_BACKEND_KEVENT 1
33 # error unsupported event loop
37 #define DISPATCH_MGR_QUEUE_DEBUG 1
38 #define DISPATCH_WLH_DEBUG 1
41 #ifndef DISPATCH_MGR_QUEUE_DEBUG
42 #define DISPATCH_MGR_QUEUE_DEBUG 0
45 #ifndef DISPATCH_WLH_DEBUG
46 #define DISPATCH_WLH_DEBUG 0
49 #ifndef DISPATCH_MACHPORT_DEBUG
50 #define DISPATCH_MACHPORT_DEBUG 0
53 #ifndef DISPATCH_TIMER_ASSERTIONS
55 #define DISPATCH_TIMER_ASSERTIONS 1
57 #define DISPATCH_TIMER_ASSERTIONS 0
61 #if DISPATCH_TIMER_ASSERTIONS
62 #define DISPATCH_TIMER_ASSERT(a, op, b, text) ({ \
64 if (unlikely(!(_a op (b)))) { \
65 DISPATCH_CLIENT_CRASH(_a, "Timer: " text); \
69 #define DISPATCH_TIMER_ASSERT(a, op, b, text) ((void)0)
73 #define EV_VANISHED 0x0200
76 #if DISPATCH_EVENT_BACKEND_KEVENT
77 # if defined(EV_SET_QOS)
78 # define DISPATCH_USE_KEVENT_QOS 1
79 # ifndef KEVENT_FLAG_IMMEDIATE
80 # define KEVENT_FLAG_IMMEDIATE 0x001
82 # ifndef KEVENT_FLAG_ERROR_EVENTS
83 # define KEVENT_FLAG_ERROR_EVENTS 0x002
86 # define DISPATCH_USE_KEVENT_QOS 0
90 # define DISPATCH_HAVE_TIMER_COALESCING 1
92 # define NOTE_LEEWAY 0
93 # define DISPATCH_HAVE_TIMER_COALESCING 0
94 # endif // !NOTE_LEEWAY
95 # if defined(NOTE_CRITICAL) && defined(NOTE_BACKGROUND)
96 # define DISPATCH_HAVE_TIMER_QOS 1
99 # define NOTE_CRITICAL 0
100 # undef NOTE_BACKGROUND
101 # define NOTE_BACKGROUND 0
102 # define DISPATCH_HAVE_TIMER_QOS 0
103 # endif // !defined(NOTE_CRITICAL) || !defined(NOTE_BACKGROUND)
105 # ifndef NOTE_FUNLOCK
106 # define NOTE_FUNLOCK 0x00000100
109 # if HAVE_DECL_NOTE_REAP
110 # if defined(NOTE_REAP) && defined(__APPLE__)
112 # define NOTE_REAP 0x10000000 // <rdar://problem/13338526>
114 # endif // HAVE_DECL_NOTE_REAP
117 # undef HAVE_DECL_VQ_QUOTA // rdar://problem/24160982
120 # ifndef VQ_NEARLOWDISK
121 # undef HAVE_DECL_VQ_NEARLOWDISK
122 # endif // VQ_NEARLOWDISK
124 # ifndef VQ_DESIRED_DISK
125 # undef HAVE_DECL_VQ_DESIRED_DISK
126 # endif // VQ_DESIRED_DISK
128 # if !defined(EVFILT_NW_CHANNEL) && defined(__APPLE__)
129 # define EVFILT_NW_CHANNEL (-16)
130 # define NOTE_FLOW_ADV_UPDATE 0x1
132 #else // DISPATCH_EVENT_BACKEND_KEVENT
133 # define EV_ADD 0x0001
134 # define EV_DELETE 0x0002
135 # define EV_ENABLE 0x0004
137 # define EV_ONESHOT 0x0010
138 # define EV_CLEAR 0x0020
139 # define EV_DISPATCH 0x0080
141 # define EVFILT_READ (-1)
142 # define EVFILT_WRITE (-2)
143 # define EVFILT_SIGNAL (-3)
144 # define EVFILT_TIMER (-4)
145 # define EVFILT_SYSCOUNT 4
147 # define DISPATCH_HAVE_TIMER_QOS 0
148 # define DISPATCH_HAVE_TIMER_COALESCING 0
149 # define KEVENT_FLAG_IMMEDIATE 0x001
150 #endif // !DISPATCH_EVENT_BACKEND_KEVENT
152 #ifdef EV_UDATA_SPECIFIC
153 # define DISPATCH_EV_DIRECT (EV_UDATA_SPECIFIC|EV_DISPATCH)
155 # define DISPATCH_EV_DIRECT 0x0000
156 # define EV_UDATA_SPECIFIC 0x0000
158 # define EV_VANISHED 0x0000
161 #define DISPATCH_EV_MSG_NEEDS_FREE 0x10000 // mach message needs to be freed()
163 #define DISPATCH_EVFILT_TIMER (-EVFILT_SYSCOUNT - 1)
164 #define DISPATCH_EVFILT_CUSTOM_ADD (-EVFILT_SYSCOUNT - 2)
165 #define DISPATCH_EVFILT_CUSTOM_OR (-EVFILT_SYSCOUNT - 3)
166 #define DISPATCH_EVFILT_CUSTOM_REPLACE (-EVFILT_SYSCOUNT - 4)
167 #define DISPATCH_EVFILT_MACH_NOTIFICATION (-EVFILT_SYSCOUNT - 5)
168 #define DISPATCH_EVFILT_SYSCOUNT ( EVFILT_SYSCOUNT + 5)
171 # if !EV_UDATA_SPECIFIC
172 # error mach support requires EV_UDATA_SPECIFIC
175 # ifndef MACH_RCV_VOUCHER
176 # define MACH_RCV_VOUCHER 0x00000800
179 # ifndef MACH_NOTIFY_SEND_POSSIBLE
180 # undef MACH_NOTIFY_SEND_POSSIBLE
181 # define MACH_NOTIFY_SEND_POSSIBLE MACH_NOTIFY_DEAD_NAME
184 # ifndef NOTE_MACH_CONTINUOUS_TIME
185 # define NOTE_MACH_CONTINUOUS_TIME 0
186 # endif // NOTE_MACH_CONTINUOUS_TIME
188 # ifndef HOST_NOTIFY_CALENDAR_SET
189 # define HOST_NOTIFY_CALENDAR_SET HOST_NOTIFY_CALENDAR_CHANGE
190 # endif // HOST_NOTIFY_CALENDAR_SET
192 # ifndef HOST_CALENDAR_SET_REPLYID
193 # define HOST_CALENDAR_SET_REPLYID 951
194 # endif // HOST_CALENDAR_SET_REPLYID
196 # ifndef MACH_SEND_OVERRIDE
197 # define MACH_SEND_OVERRIDE 0x00000020
198 typedef unsigned int mach_msg_priority_t
;
199 # define MACH_MSG_PRIORITY_UNSPECIFIED ((mach_msg_priority_t)0)
200 # endif // MACH_SEND_OVERRIDE
202 # ifndef MACH_SEND_SYNC_OVERRIDE
203 # define MACH_SEND_SYNC_OVERRIDE 0x00100000
204 # endif // MACH_SEND_SYNC_OVERRIDE
206 # ifndef MACH_RCV_SYNC_WAIT
207 # define MACH_RCV_SYNC_WAIT 0x00004000
208 # endif // MACH_RCV_SYNC_WAIT
210 # define DISPATCH_MACH_TRAILER_SIZE sizeof(dispatch_mach_trailer_t)
211 # define DISPATCH_MACH_RCV_TRAILER MACH_RCV_TRAILER_CTX
212 # define DISPATCH_MACH_RCV_OPTIONS ( \
213 MACH_RCV_MSG | MACH_RCV_LARGE | MACH_RCV_LARGE_IDENTITY | \
214 MACH_RCV_TRAILER_ELEMENTS(DISPATCH_MACH_RCV_TRAILER) | \
215 MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) | \
219 #endif // __DISPATCH_EVENT_EVENT_CONFIG__