]> git.saurik.com Git - apple/libdispatch.git/blob - src/legacy.h
libdispatch-84.5.5.tar.gz
[apple/libdispatch.git] / src / legacy.h
1 /*
2 * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
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.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21 /*
22 * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
23 * which are subject to change in future releases of Mac OS X. Any applications
24 * relying on these interfaces WILL break.
25 */
26
27 /*
28 * LEGACY: This header file describles LEGACY interfaces to libdispatch from an
29 * earlier revision of the API. These interfaces WILL be removed in the future.
30 */
31
32 #ifndef __DISPATCH_LEGACY__
33 #define __DISPATCH_LEGACY__
34
35 #ifndef __DISPATCH_INDIRECT__
36 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
37 #include <dispatch/base.h> // for HeaderDoc
38 #endif
39
40 #include <mach/mach_types.h>
41
42 #define DISPATCH_DEPRECATED __attribute__((deprecated))
43 #define DISPATCH_PUBLIC_API __attribute__((visibility("default")))
44
45 typedef struct dispatch_item_s *dispatch_item_t;
46
47 struct dispatch_item_s {
48 void * di_objc_isa; /* FIXME -- someday... */
49 struct dispatch_item_s *volatile di_next;
50 dispatch_queue_t di_cback_q;
51 uint32_t di_flags;
52 semaphore_t di_semaphore;
53 void * di_work_func;
54 void * di_work_ctxt;
55 void * di_cback_func;
56 void * di_cback_ctxt;
57 void * di_ctxt;
58 };
59
60 // Use: dispatch_source_t
61 typedef struct dispatch_source_s *dispatch_event_t;
62
63 // Obsolete
64 #ifdef __BLOCKS__
65 typedef void (^dispatch_legacy_block_t)(dispatch_item_t);
66 typedef void (^dispatch_queue_deletion_block_t)(dispatch_queue_t queue);
67 typedef void (^dispatch_source_deletion_t)(dispatch_source_t source);
68 typedef void (^dispatch_event_callback_t)(dispatch_event_t event);
69 typedef void (^dispatch_source_handler_t)(dispatch_source_t source);
70 typedef dispatch_source_handler_t dispatch_event_handler_t;
71 typedef void (^dispatch_source_finalizer_t)(dispatch_source_t source);
72 #endif /* __BLOCKS__ */
73
74 // Obsolete
75 typedef void (*dispatch_source_handler_function_t)(void *, dispatch_source_t);
76 typedef void (*dispatch_source_finalizer_function_t)(void *, dispatch_source_t);
77 typedef dispatch_source_handler_function_t dispatch_event_handler_function_t;
78
79 DISPATCH_DECL(dispatch_source_attr);
80
81 #define DISPATCH_SOURCE_CREATE_SUSPENDED ((dispatch_source_attr_t)~0ul)
82
83 #ifdef __BLOCKS__
84 typedef void (^dispatch_queue_finalizer_t)(dispatch_queue_t queue);
85 #endif
86
87 typedef void (*dispatch_queue_finalizer_function_t)(void *, dispatch_queue_t);
88
89 __BEGIN_DECLS
90
91 /*!
92 * @function dispatch_queue_attr_create
93 *
94 * @abstract
95 * Creates a new dispatch queue attribute structure. These attributes may be
96 * provided at creation time to modify the default behavior of the queue.
97 *
98 * @discussion
99 * The values present in this structure are copied to newly created queues.
100 * The same attribute structure may be provided to multiple calls to
101 * dispatch_queue_create() but only the values in the structure at the time the
102 * call is made will be used.
103 *
104 * @result
105 * The new dispatch queue attribute structure, initialized to default values.
106 */
107 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
108 DISPATCH_MALLOC DISPATCH_WARN_RESULT DISPATCH_NOTHROW
109 dispatch_queue_attr_t
110 dispatch_queue_attr_create(void);
111
112 /*!
113 * @function dispatch_queue_attr_set_priority
114 *
115 * @abstract
116 * Set the priority level for a dispatch queue.
117 *
118 * @discussion
119 * Priority levels may be:
120 * - DISPATCH_QUEUE_PRIORITY_HIGH
121 * - DISPATCH_QUEUE_PRIORITY_DEFAULT
122 * - DISPATCH_QUEUE_PRIORITY_LOW
123 * Queues set to high priority will be processed
124 * before queues set to default priority or low priority.
125 * Queues set to low priority will be processed only if all
126 * high priority and default priority queues are empty.
127 */
128 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
129 DISPATCH_NONNULL1 DISPATCH_NOTHROW
130 void
131 dispatch_queue_attr_set_priority(dispatch_queue_attr_t attr, int priority);
132
133 #ifdef __BLOCKS__
134 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
135 DISPATCH_NONNULL1 DISPATCH_NOTHROW
136 long
137 dispatch_queue_attr_set_finalizer(
138 dispatch_queue_attr_t attr,
139 dispatch_queue_finalizer_t finalizer);
140 #endif
141
142 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
143 DISPATCH_NONNULL1 DISPATCH_NOTHROW
144 void
145 dispatch_queue_attr_set_finalizer_f(dispatch_queue_attr_t attr, void *context, dispatch_queue_finalizer_function_t finalizer);
146
147 /*!
148 * @function dispatch_get_concurrent_queue
149 *
150 * @abstract
151 * Returns a well-known global concurrent queue of a given priority level.
152 *
153 * @discussion
154 * Blocks submitted to the returned queue may be invoked concurrently with
155 * respect to each other.
156 *
157 * These queues are useful for performing one-shot asynchronous operations,
158 * e.g. dispatch_async() to an "anonymous" queue; or for performing parallel
159 * loops concurrently on multiple processors, e.g. dispatch_apply().
160 *
161 * The dispatch queues returned by this function are managed by the system for
162 * the lifetime of the application, and need not be retained or released
163 * directly by the application. Furthermore, dispatch_suspend() and
164 * dispatch_queue_resume() are not supported on these global queues, and will
165 * be ignored.
166 *
167 * @param priority
168 * The requested priority level for the queue (default is zero):
169 * - DISPATCH_QUEUE_PRIORITY_HIGH
170 * - DISPATCH_QUEUE_PRIORITY_DEFAULT
171 * - DISPATCH_QUEUE_PRIORITY_LOW
172 *
173 * @result
174 * Returns a concurrent dispatch queue for use with dispatch_async(),
175 * dispatch_apply(), et al.
176 */
177 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
178 DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
179 dispatch_queue_t
180 dispatch_get_concurrent_queue(long priority);
181
182 DISPATCH_PUBLIC_API //DISPATCH_DEPRECATED
183 void
184 dispatch_queue_attr_set_flags(dispatch_queue_attr_t attr, uint64_t flags);
185
186 #ifdef __BLOCKS__
187 DISPATCH_PUBLIC_API DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_DEPRECATED
188 dispatch_item_t
189 dispatch_call(dispatch_queue_t, dispatch_legacy_block_t work, dispatch_legacy_block_t completion)
190 __asm__("_dispatch_call2");
191 #endif /* __BLOCKS__ */
192
193 DISPATCH_PUBLIC_API DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_DEPRECATED
194 dispatch_queue_t
195 dispatch_queue_get_current(void);
196
197 // Use: dispatch_retain
198 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
199 void
200 dispatch_queue_retain(dispatch_queue_t);
201
202 // Use: dispatch_release
203 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
204 void
205 dispatch_queue_release(dispatch_queue_t);
206
207 // Use: dispatch_resume
208 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
209 void
210 dispatch_queue_resume(dispatch_queue_t);
211
212 // Use: dispatch_release
213 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
214 void
215 dispatch_source_release(dispatch_source_t);
216
217 // Use: dispatch_suspend
218 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
219 void
220 dispatch_source_suspend(dispatch_source_t);
221
222 // Use: dispatch_resume
223 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
224 void
225 dispatch_source_resume(dispatch_source_t);
226
227 // Use: dispatch_release
228 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
229 void
230 dispatch_queue_attr_release(dispatch_queue_attr_t);
231
232 // Use: dispatch_release
233 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
234 void
235 dispatch_source_attr_release(dispatch_source_attr_t);
236
237 // Use: dispatch_source_get_handle
238 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_DEPRECATED
239 sigset_t
240 dispatch_event_get_signals(dispatch_event_t event);
241
242 // Use: dispatch_get_context
243 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL //DISPATCH_DEPRECATED
244 void *
245 dispatch_queue_get_context(dispatch_queue_t queue);
246
247 // Use: dispatch_set_context
248 DISPATCH_PUBLIC_API DISPATCH_NONNULL1 //DISPATCH_DEPRECATED
249 void
250 dispatch_queue_set_context(dispatch_queue_t queue, void *context);
251
252 // Use: dispatch_get_context
253 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL //DISPATCH_DEPRECATED
254 void *
255 dispatch_source_get_context(dispatch_source_t source);
256
257 // Use: dispatch_set_context
258 DISPATCH_PUBLIC_API DISPATCH_NONNULL1 //DISPATCH_DEPRECATED
259 void
260 dispatch_source_set_context(dispatch_source_t source, void * context);
261
262 // Use: dispatch_source_merge_data
263 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
264 void
265 dispatch_source_custom_trigger(dispatch_source_t ds);
266
267 // Use: dispatch_source_cancel
268 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
269 DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
270 void
271 dispatch_cancel(dispatch_source_t);
272
273 // Use: dispatch_source_testcancel
274 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
275 DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
276 long
277 dispatch_testcancel(dispatch_source_t);
278
279 // Use: dispatch_source_set_timer
280 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
281 DISPATCH_NONNULL1 DISPATCH_NOTHROW
282 long
283 dispatch_source_timer_set_time(dispatch_source_t ds,
284 uint64_t nanoseconds,
285 uint64_t leeway);
286
287 // Use: dispatch_source_merge_data
288 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
289 DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
290 void
291 dispatch_source_trigger(dispatch_source_t source, unsigned long value);
292
293 enum {
294 DISPATCH_ERROR_DOMAIN_NO_ERROR = 0,
295 DISPATCH_ERROR_DOMAIN_POSIX = 1,
296 DISPATCH_ERROR_DOMAIN_MACH = 2,
297 };
298
299 // Obsolete
300 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
301 DISPATCH_NONNULL1 DISPATCH_WARN_RESULT DISPATCH_NOTHROW
302 long
303 dispatch_source_get_error(dispatch_source_t source, long* error);
304
305 // Use: dispatch_source_get_handle
306 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
307 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
308 mach_port_t
309 dispatch_source_get_machport(dispatch_source_t source);
310
311 // Use: dispatch_source_get_handle
312 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
313 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
314 pid_t
315 dispatch_source_get_descriptor(dispatch_source_t source);
316
317 // Use: dispatch_source_get_handle
318 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
319 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
320 pid_t
321 dispatch_source_get_pid(dispatch_source_t source);
322
323 // Use: dispatch_source_get_mask
324 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
325 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
326 uint64_t
327 dispatch_source_get_flags(dispatch_source_t source);
328
329 // LEGACY: dispatch_event_t == dispatch_source_t
330 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
331 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
332 dispatch_source_t
333 dispatch_event_get_source(dispatch_event_t event);
334
335 // Use: dispatch_source_get_error
336 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
337 DISPATCH_NONNULL1 DISPATCH_WARN_RESULT DISPATCH_NOTHROW
338 long
339 dispatch_event_get_error(dispatch_event_t event, long* error);
340
341 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
342 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
343 uint64_t
344 dispatch_event_get_nanoseconds(dispatch_event_t event);
345
346 // Use: dispatch_source_get_handle
347 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
348 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
349 long
350 dispatch_event_get_signal(dispatch_event_t event);
351
352 // Use: dispatch_source_get_data
353 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
354 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
355 uint64_t
356 dispatch_event_get_flags(dispatch_event_t event);
357
358 // Use: dispatch_source_get_data
359 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
360 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
361 size_t
362 dispatch_event_get_bytes_available(dispatch_event_t event);
363
364 // Use: dispatch_source_get_data
365 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
366 DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
367 unsigned long
368 dispatch_event_get_count(dispatch_event_t event);
369
370 // Obsolete
371 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
372 DISPATCH_MALLOC DISPATCH_WARN_RESULT DISPATCH_NOTHROW
373 dispatch_source_attr_t
374 dispatch_source_attr_create(void);
375
376 // Obsolete
377 #if defined(__BLOCKS__)
378 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
379 DISPATCH_NOTHROW
380 dispatch_source_finalizer_t
381 dispatch_source_attr_get_finalizer(dispatch_source_attr_t attr);
382 #endif /* __BLOCKS__ */
383
384 // Obsolete
385 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
386 DISPATCH_MALLOC DISPATCH_WARN_RESULT DISPATCH_NOTHROW
387 dispatch_source_attr_t
388 dispatch_source_attr_copy(dispatch_source_attr_t proto);
389
390 // Obsolete
391 #ifdef __BLOCKS__
392 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
393 DISPATCH_NONNULL1 DISPATCH_NOTHROW
394 long
395 dispatch_source_attr_set_finalizer(
396 dispatch_source_attr_t attr,
397 dispatch_source_finalizer_t finalizer);
398 #endif /* __BLOCKS__ */
399
400 // Obsolete
401 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
402 DISPATCH_NONNULL1 DISPATCH_NOTHROW
403 void
404 dispatch_source_attr_set_finalizer_f(
405 dispatch_source_attr_t attr,
406 void *context,
407 dispatch_source_finalizer_function_t finalizer);
408
409 // Obsolete
410 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
411 DISPATCH_NONNULL1 DISPATCH_NOTHROW
412 void
413 dispatch_source_attr_set_context(
414 dispatch_source_attr_t attr,
415 void *context);
416
417 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, ...)
418 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
419 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL5 DISPATCH_NOTHROW
420 dispatch_source_t
421 dispatch_source_mig_create(
422 mach_port_t mport,
423 size_t max_size,
424 dispatch_source_attr_t attr,
425 dispatch_queue_t queue,
426 dispatch_mig_callback_t mig_callback);
427
428 enum {
429 DISPATCH_TIMER_WALL_CLOCK = 0x4,
430 };
431
432 enum {
433 DISPATCH_TIMER_INTERVAL = 0x0,
434 DISPATCH_TIMER_ONESHOT = 0x1,
435 DISPATCH_TIMER_ABSOLUTE = 0x3,
436 };
437
438 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, ...)
439 #ifdef __BLOCKS__
440 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
441 DISPATCH_MALLOC DISPATCH_NONNULL5 DISPATCH_NONNULL6 DISPATCH_NOTHROW
442 dispatch_source_t
443 dispatch_source_timer_create(
444 uint64_t flags,
445 uint64_t nanoseconds,
446 uint64_t leeway,
447 dispatch_source_attr_t attr,
448 dispatch_queue_t queue,
449 dispatch_source_handler_t handler);
450 #endif /* __BLOCKS__ */
451
452 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, ...)
453 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
454 DISPATCH_MALLOC DISPATCH_NONNULL5 DISPATCH_NONNULL7 DISPATCH_NOTHROW
455 dispatch_source_t
456 dispatch_source_timer_create_f(
457 uint64_t flags,
458 uint64_t nanoseconds,
459 uint64_t leeway,
460 dispatch_source_attr_t attr,
461 dispatch_queue_t queue,
462 void *h_context,
463 dispatch_source_handler_function_t handler);
464
465 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, ...)
466 #ifdef __BLOCKS__
467 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
468 DISPATCH_MALLOC DISPATCH_NOTHROW
469 dispatch_source_t
470 dispatch_source_signal_create(
471 unsigned long signo,
472 dispatch_source_attr_t attr,
473 dispatch_queue_t queue,
474 dispatch_source_handler_t handler);
475 #endif /* __BLOCKS__ */
476
477 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, ...)
478 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
479 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
480 dispatch_source_t
481 dispatch_source_signal_create_f(
482 unsigned long sig,
483 dispatch_source_attr_t attr,
484 dispatch_queue_t queue,
485 void *h_context,
486 dispatch_source_handler_function_t handler);
487
488 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, ...)
489 #ifdef __BLOCKS__
490 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
491 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
492 dispatch_source_t
493 dispatch_source_read_create(
494 int descriptor,
495 dispatch_source_attr_t attr,
496 dispatch_queue_t queue,
497 dispatch_source_handler_t handler);
498 #endif /* __BLOCKS__ */
499
500 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, ...)
501 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
502 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
503 dispatch_source_t
504 dispatch_source_read_create_f(
505 int descriptor,
506 dispatch_source_attr_t attr,
507 dispatch_queue_t queue,
508 void *h_context,
509 dispatch_source_handler_function_t handler);
510
511 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE, ...)
512 #ifdef __BLOCKS__
513 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
514 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
515 dispatch_source_t
516 dispatch_source_write_create(
517 int descriptor,
518 dispatch_source_attr_t attr,
519 dispatch_queue_t queue,
520 dispatch_source_handler_t handler);
521 #endif /* __BLOCKS__ */
522
523 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE, ...)
524 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
525 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
526 dispatch_source_t
527 dispatch_source_write_create_f(
528 int descriptor,
529 dispatch_source_attr_t attr,
530 dispatch_queue_t queue,
531 void *h_context,
532 dispatch_source_handler_function_t handler);
533
534 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, ...)
535 #ifdef __BLOCKS__
536 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
537 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL5 DISPATCH_NOTHROW
538 dispatch_source_t
539 dispatch_source_vnode_create(
540 int descriptor,
541 uint64_t flags,
542 dispatch_source_attr_t attr,
543 dispatch_queue_t queue,
544 dispatch_source_handler_t handler);
545 #endif /* __BLOCKS__ */
546
547 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, ...)
548 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
549 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL6 DISPATCH_NOTHROW
550 dispatch_source_t
551 dispatch_source_vnode_create_f(
552 int descriptor,
553 uint64_t flags,
554 dispatch_source_attr_t attr,
555 dispatch_queue_t queue,
556 void *h_context,
557 dispatch_source_handler_function_t handler);
558
559 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, ...)
560 #ifdef __BLOCKS__
561 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
562 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL5 DISPATCH_NOTHROW
563 dispatch_source_t
564 dispatch_source_proc_create(
565 pid_t pid,
566 uint64_t flags,
567 dispatch_source_attr_t attr,
568 dispatch_queue_t queue,
569 dispatch_source_handler_t handler);
570 #endif /* __BLOCKS__ */
571
572 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, ...)
573 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
574 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL6 DISPATCH_NOTHROW
575 dispatch_source_t
576 dispatch_source_proc_create_f(
577 pid_t pid,
578 uint64_t flags,
579 dispatch_source_attr_t attr,
580 dispatch_queue_t queue,
581 void *h_context,
582 dispatch_source_handler_function_t handler);
583
584 enum {
585 DISPATCH_MACHPORT_DEAD = 0x1,
586 DISPATCH_MACHPORT_RECV = 0x2,
587 DISPATCH_MACHPORT_DELETED = 0x4,
588 };
589
590 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, ...)
591 #ifdef __BLOCKS__
592 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
593 DISPATCH_MALLOC DISPATCH_NOTHROW
594 dispatch_source_t
595 dispatch_source_machport_create(
596 mach_port_t mport,
597 uint64_t flags,
598 dispatch_source_attr_t attr,
599 dispatch_queue_t queue,
600 dispatch_source_handler_t handler);
601 #endif /* __BLOCKS__ */
602
603 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, ...)
604 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
605 DISPATCH_MALLOC DISPATCH_NOTHROW
606 dispatch_source_t
607 dispatch_source_machport_create_f(
608 mach_port_t mport,
609 uint64_t flags,
610 dispatch_source_attr_t attr,
611 dispatch_queue_t queue,
612 void *h_context,
613 dispatch_source_handler_function_t handler);
614
615 enum {
616 DISPATCH_SOURCE_DATA_ADD = 1,
617 DISPATCH_SOURCE_DATA_OR,
618 };
619
620 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA..., ...)
621 #ifdef __BLOCKS__
622 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
623 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
624 dispatch_source_t
625 dispatch_source_data_create(
626 unsigned long behavior,
627 dispatch_source_attr_t attr,
628 dispatch_queue_t queue,
629 dispatch_source_handler_t handler);
630 #endif /* __BLOCKS__ */
631
632 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA..., ...)
633 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
634 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
635 dispatch_source_t
636 dispatch_source_data_create_f(
637 unsigned long behavior,
638 dispatch_source_attr_t attr,
639 dispatch_queue_t queue,
640 void *h_context,
641 dispatch_source_handler_function_t handler);
642
643 enum {
644 DISPATCH_SOURCE_CUSTOM_ADD = DISPATCH_SOURCE_DATA_ADD,
645 DISPATCH_SOURCE_CUSTOM_OR = DISPATCH_SOURCE_DATA_OR,
646 };
647
648 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA..., ...)
649 #ifdef __BLOCKS__
650 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
651 DISPATCH_MALLOC DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NOTHROW
652 dispatch_source_t
653 dispatch_source_custom_create(
654 unsigned long behavior,
655 dispatch_source_attr_t attr,
656 dispatch_queue_t queue,
657 dispatch_event_handler_t handler);
658 #endif /* __BLOCKS__ */
659
660 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA..., ...)
661 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
662 DISPATCH_MALLOC DISPATCH_NONNULL2 DISPATCH_NONNULL4 DISPATCH_NOTHROW
663 dispatch_source_t
664 dispatch_source_custom_create_f(
665 unsigned long behavior,
666 dispatch_source_attr_t attr,
667 dispatch_queue_t queue,
668 void *h_context,
669 dispatch_event_handler_function_t handler);
670
671 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_VFS, ...)
672 #if defined(__BLOCKS__)
673 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
674 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL4
675 dispatch_source_t
676 dispatch_source_vfs_create(
677 uint64_t flags,
678 dispatch_source_attr_t attr,
679 dispatch_queue_t queue,
680 dispatch_source_handler_t handler);
681 #endif /* __BLOCKS__ */
682
683 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_VFS, ...)
684 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
685 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5
686 dispatch_source_t
687 dispatch_source_vfs_create_f(
688 uint64_t flags,
689 dispatch_source_attr_t attr,
690 dispatch_queue_t queue,
691 void *h_context,
692 dispatch_source_handler_function_t handler);
693
694 /*
695 * Raw Mach message support from MIG source.
696 *
697 * It is possible to use the following callback style with the MIG source to
698 * obtain the raw mach message (and send no reply) similar to CFMachPort.
699 * (For more specific CFMachPort compatibility, see below).
700 *
701 * void handle_mach_msg(mach_msg_header *msg) { ... }
702 * ...
703 * DISPATCH_MACHPORT_CALLBACK_DECL(mig_compat_callback, handle_mach_msg);
704 * ...
705 * mig = dispatch_source_mig_create(mp, MY_MAX_MSG_SIZE, NULL,
706 * queue, mig_compat_callback);
707 */
708 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
709 boolean_t
710 _dispatch_machport_callback(mach_msg_header_t *msg, mach_msg_header_t *reply, void (*callback)(mach_msg_header_t *));
711
712 #define DISPATCH_MACHPORT_CALLBACK_DECL(new_callback, existing_callback) \
713 __private_extern__ boolean_t \
714 new_callback(mach_msg_header_t *msg, mach_msg_header_t *reply) \
715 { return _dispatch_machport_callback(msg, reply, existing_callback); }
716
717 /*
718 * CFMachPort compatibility.
719 *
720 * It is possible to use existing CFMachPort callbacks with dispatch mig sources
721 * by delcaring the following shim and using the shim as the mig server callback
722 * to dispatch_source_mig_create().
723 * The CFMachPortRef "port" parameter of the CFMachPortCallBack will be NULL.
724 * If mach_port_set_context() is used, that value will be passed into the "info"
725 * parameter of the CFMachPortCallBack.
726 *
727 * DISPATCH_CFMACHPORT_CALLBACK_DECL(mig_callback, MyCFMachPortCallBack);
728 *
729 * ...
730 * {
731 * kr = mach_port_set_context(mach_task_self(), mp, (mach_vm_address_t)context);
732 * mig = dispatch_source_mig_create(mp, MY_MAX_MSG_SIZE, NULL,
733 * queue, mig_callback);
734 */
735 struct __CFMachPort;
736
737 __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_NA)
738 boolean_t
739 _dispatch_CFMachPortCallBack(mach_msg_header_t *msg, mach_msg_header_t *reply, void (*callback)(struct __CFMachPort *, void *msg, signed long size, void *));
740
741 #define DISPATCH_CFMACHPORT_CALLBACK_DECL(new_callback, existing_callback) \
742 __private_extern__ boolean_t \
743 new_callback(mach_msg_header_t *msg, mach_msg_header_t *reply) \
744 { return _dispatch_CFMachPortCallBack(msg, reply, existing_callback); }
745
746 __END_DECLS
747
748 #endif