2 * Copyright (c) 2008-2011 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 // Contains exported global data and initialization & other routines that must
22 // only exist once in the shared library even when resolvers are used.
27 #include "protocolServer.h"
31 #pragma mark dispatch_init
33 #if USE_LIBDISPATCH_INIT_CONSTRUCTOR
34 DISPATCH_NOTHROW
__attribute__((constructor
))
36 _libdispatch_init(void);
38 DISPATCH_EXPORT DISPATCH_NOTHROW
40 _libdispatch_init(void)
46 DISPATCH_EXPORT DISPATCH_NOTHROW
48 dispatch_atfork_prepare(void)
52 DISPATCH_EXPORT DISPATCH_NOTHROW
54 dispatch_atfork_parent(void)
64 dummy_function_r0(void)
70 #pragma mark dispatch_globals
72 #if DISPATCH_COCOA_COMPAT
73 void (*dispatch_begin_thread_4GC
)(void);
74 void (*dispatch_end_thread_4GC
)(void);
75 void (*dispatch_no_worker_threads_4GC
)(void);
76 void *(*_dispatch_begin_NSAutoReleasePool
)(void);
77 void (*_dispatch_end_NSAutoReleasePool
)(void *);
80 #if !DISPATCH_USE_DIRECT_TSD
81 pthread_key_t dispatch_queue_key
;
82 pthread_key_t dispatch_sema4_key
;
83 pthread_key_t dispatch_cache_key
;
84 pthread_key_t dispatch_io_key
;
85 pthread_key_t dispatch_apply_key
;
87 pthread_key_t dispatch_bcounter_key
;
89 #endif // !DISPATCH_USE_DIRECT_TSD
91 struct _dispatch_hw_config_s _dispatch_hw_config
;
92 bool _dispatch_safe_fork
= true;
96 _dispatch_is_multithreaded(void)
98 return !_dispatch_safe_fork
;
101 const struct dispatch_queue_offsets_s dispatch_queue_offsets
= {
103 .dqo_label
= offsetof(struct dispatch_queue_s
, dq_label
),
104 .dqo_label_size
= sizeof(((dispatch_queue_t
)NULL
)->dq_label
),
107 .dqo_width
= offsetof(struct dispatch_queue_s
, dq_width
),
108 .dqo_width_size
= sizeof(((dispatch_queue_t
)NULL
)->dq_width
),
109 .dqo_serialnum
= offsetof(struct dispatch_queue_s
, dq_serialnum
),
110 .dqo_serialnum_size
= sizeof(((dispatch_queue_t
)NULL
)->dq_serialnum
),
111 .dqo_running
= offsetof(struct dispatch_queue_s
, dq_running
),
112 .dqo_running_size
= sizeof(((dispatch_queue_t
)NULL
)->dq_running
),
115 // 6618342 Contact the team that owns the Instrument DTrace probe before
116 // renaming this symbol
117 DISPATCH_CACHELINE_ALIGN
118 struct dispatch_queue_s _dispatch_main_q
= {
119 .do_vtable
= DISPATCH_VTABLE(queue
),
120 #if !DISPATCH_USE_RESOLVERS
121 .do_targetq
= &_dispatch_root_queues
[
122 DISPATCH_ROOT_QUEUE_IDX_DEFAULT_OVERCOMMIT_PRIORITY
],
124 .do_ref_cnt
= DISPATCH_OBJECT_GLOBAL_REFCNT
,
125 .do_xref_cnt
= DISPATCH_OBJECT_GLOBAL_REFCNT
,
126 .do_suspend_cnt
= DISPATCH_OBJECT_SUSPEND_LOCK
,
127 .dq_label
= "com.apple.main-thread",
133 struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent
= {
134 .do_vtable
= DISPATCH_VTABLE(queue_attr
),
135 .do_ref_cnt
= DISPATCH_OBJECT_GLOBAL_REFCNT
,
136 .do_xref_cnt
= DISPATCH_OBJECT_GLOBAL_REFCNT
,
137 .do_next
= DISPATCH_OBJECT_LISTLESS
,
141 #pragma mark dispatch_vtables
143 DISPATCH_VTABLE_INSTANCE(semaphore
,
144 .do_type
= DISPATCH_SEMAPHORE_TYPE
,
145 .do_kind
= "semaphore",
146 .do_dispose
= _dispatch_semaphore_dispose
,
147 .do_debug
= _dispatch_semaphore_debug
,
150 DISPATCH_VTABLE_INSTANCE(group
,
151 .do_type
= DISPATCH_GROUP_TYPE
,
153 .do_dispose
= _dispatch_semaphore_dispose
,
154 .do_debug
= _dispatch_semaphore_debug
,
157 DISPATCH_VTABLE_INSTANCE(queue
,
158 .do_type
= DISPATCH_QUEUE_TYPE
,
160 .do_dispose
= _dispatch_queue_dispose
,
162 .do_probe
= (void *)dummy_function_r0
,
163 .do_debug
= dispatch_queue_debug
,
166 DISPATCH_VTABLE_SUBCLASS_INSTANCE(queue_root
, queue
,
167 .do_type
= DISPATCH_QUEUE_GLOBAL_TYPE
,
168 .do_kind
= "global-queue",
169 .do_debug
= dispatch_queue_debug
,
170 .do_probe
= _dispatch_queue_probe_root
,
173 DISPATCH_VTABLE_SUBCLASS_INSTANCE(queue_mgr
, queue
,
174 .do_type
= DISPATCH_QUEUE_MGR_TYPE
,
175 .do_kind
= "mgr-queue",
176 .do_invoke
= _dispatch_mgr_thread
,
177 .do_debug
= dispatch_queue_debug
,
178 .do_probe
= _dispatch_mgr_wakeup
,
181 DISPATCH_VTABLE_INSTANCE(queue_specific_queue
,
182 .do_type
= DISPATCH_QUEUE_SPECIFIC_TYPE
,
183 .do_kind
= "queue-context",
184 .do_dispose
= _dispatch_queue_specific_queue_dispose
,
186 .do_probe
= (void *)dummy_function_r0
,
187 .do_debug
= (void *)dispatch_queue_debug
,
190 DISPATCH_VTABLE_INSTANCE(queue_attr
,
191 .do_type
= DISPATCH_QUEUE_ATTR_TYPE
,
192 .do_kind
= "queue-attr",
195 DISPATCH_VTABLE_INSTANCE(source
,
196 .do_type
= DISPATCH_SOURCE_KEVENT_TYPE
,
197 .do_kind
= "kevent-source",
198 .do_invoke
= _dispatch_source_invoke
,
199 .do_dispose
= _dispatch_source_dispose
,
200 .do_probe
= _dispatch_source_probe
,
201 .do_debug
= _dispatch_source_debug
,
204 DISPATCH_VTABLE_INSTANCE(data
,
205 .do_type
= DISPATCH_DATA_TYPE
,
207 .do_dispose
= _dispatch_data_dispose
,
209 .do_probe
= (void *)dummy_function_r0
,
210 .do_debug
= _dispatch_data_debug
,
213 DISPATCH_VTABLE_INSTANCE(io
,
214 .do_type
= DISPATCH_IO_TYPE
,
215 .do_kind
= "channel",
216 .do_dispose
= _dispatch_io_dispose
,
218 .do_probe
= (void *)dummy_function_r0
,
219 .do_debug
= (void *)dummy_function_r0
,
222 DISPATCH_VTABLE_INSTANCE(operation
,
223 .do_type
= DISPATCH_OPERATION_TYPE
,
224 .do_kind
= "operation",
225 .do_dispose
= _dispatch_operation_dispose
,
227 .do_probe
= (void *)dummy_function_r0
,
228 .do_debug
= (void *)dummy_function_r0
,
231 DISPATCH_VTABLE_INSTANCE(disk
,
232 .do_type
= DISPATCH_DISK_TYPE
,
234 .do_dispose
= _dispatch_disk_dispose
,
236 .do_probe
= (void *)dummy_function_r0
,
237 .do_debug
= (void *)dummy_function_r0
,
241 _dispatch_vtable_init(void)
244 // ObjC classes and dispatch vtables are co-located via linker order and
245 // alias files, verify correct layout during initialization rdar://10640168
246 #define DISPATCH_OBJC_CLASS(name) \
247 DISPATCH_CONCAT(OBJC_CLASS_$_,DISPATCH_CLASS(name))
248 extern void *DISPATCH_OBJC_CLASS(semaphore
);
249 dispatch_assert((char*)DISPATCH_VTABLE(semaphore
) -
250 (char*)&DISPATCH_OBJC_CLASS(semaphore
) == 0);
251 dispatch_assert((char*)&DISPATCH_CONCAT(_
,DISPATCH_CLASS(semaphore_vtable
))
252 - (char*)&DISPATCH_OBJC_CLASS(semaphore
) ==
253 sizeof(_os_object_class_s
));
258 #pragma mark dispatch_bug
260 static char _dispatch_build
[16];
263 _dispatch_build_init(void *context DISPATCH_UNUSED
)
266 int mib
[] = { CTL_KERN
, KERN_OSVERSION
};
267 size_t bufsz
= sizeof(_dispatch_build
);
269 sysctl(mib
, 2, _dispatch_build
, &bufsz
, NULL
, 0);
272 * XXXRW: What to do here for !Mac OS X?
274 memset(_dispatch_build
, 0, sizeof(_dispatch_build
));
278 #define _dispatch_bug_log(msg, ...) do { \
279 static void *last_seen; \
280 void *ra = __builtin_return_address(0); \
281 if (last_seen != ra) { \
283 _dispatch_log((msg), ##__VA_ARGS__); \
288 _dispatch_bug(size_t line
, long val
)
290 static dispatch_once_t pred
;
292 dispatch_once_f(&pred
, NULL
, _dispatch_build_init
);
293 _dispatch_bug_log("BUG in libdispatch: %s - %lu - 0x%lx",
294 _dispatch_build
, (unsigned long)line
, val
);
298 _dispatch_bug_client(const char* msg
)
300 _dispatch_bug_log("BUG in libdispatch client: %s", msg
);
304 _dispatch_bug_mach_client(const char* msg
, mach_msg_return_t kr
)
306 _dispatch_bug_log("BUG in libdispatch client: %s %s - 0x%x", msg
,
307 mach_error_string(kr
), kr
);
311 _dispatch_abort(size_t line
, long val
)
313 _dispatch_bug(line
, val
);
318 #pragma mark dispatch_log
320 static FILE *dispatch_logfile
;
321 static bool dispatch_log_disabled
;
322 static dispatch_once_t _dispatch_logv_pred
;
325 _dispatch_logv_init(void *context DISPATCH_UNUSED
)
328 bool log_to_file
= true;
330 bool log_to_file
= false;
332 char *e
= getenv("LIBDISPATCH_LOG");
334 if (strcmp(e
, "YES") == 0) {
336 } else if (strcmp(e
, "NO") == 0) {
337 dispatch_log_disabled
= true;
338 } else if (strcmp(e
, "syslog") == 0) {
340 } else if (strcmp(e
, "file") == 0) {
342 } else if (strcmp(e
, "stderr") == 0) {
344 dispatch_logfile
= stderr
;
347 if (!dispatch_log_disabled
) {
348 if (log_to_file
&& !dispatch_logfile
) {
350 snprintf(path
, sizeof(path
), "/var/tmp/libdispatch.%d.log",
352 dispatch_logfile
= fopen(path
, "a");
354 if (dispatch_logfile
) {
356 gettimeofday(&tv
, NULL
);
357 fprintf(dispatch_logfile
, "=== log file opened for %s[%u] at "
358 "%ld.%06u ===\n", getprogname() ?: "", getpid(),
359 tv
.tv_sec
, tv
.tv_usec
);
360 fflush(dispatch_logfile
);
367 _dispatch_logv_file(const char *msg
, va_list ap
)
372 len
= vasprintf(&buf
, msg
, ap
);
374 fwrite(buf
, 1, len
, dispatch_logfile
);
375 fflush(dispatch_logfile
);
380 _dispatch_logv(const char *msg
, va_list ap
)
382 dispatch_once_f(&_dispatch_logv_pred
, NULL
, _dispatch_logv_init
);
383 if (slowpath(dispatch_log_disabled
)) {
386 if (slowpath(dispatch_logfile
)) {
387 return _dispatch_logv_file(msg
, ap
);
389 vsyslog(LOG_NOTICE
, msg
, ap
);
394 _dispatch_log(const char *msg
, ...)
399 _dispatch_logv(msg
, ap
);
404 #pragma mark dispatch_debug
408 dispatch_debugv(dispatch_object_t dou
, const char *msg
, va_list ap
)
413 if (dou
._do
&& dou
._do
->do_vtable
->do_debug
) {
414 offs
= dx_debug(dou
._do
, buf
, sizeof(buf
));
416 offs
= snprintf(buf
, sizeof(buf
), "NULL vtable slot");
419 snprintf(buf
+ offs
, sizeof(buf
) - offs
, ": %s", msg
);
420 _dispatch_logv(buf
, ap
);
425 dispatch_debug(dispatch_object_t dou
, const char *msg
, ...)
430 dispatch_debugv(dou
._do
, msg
, ap
);
435 #pragma mark dispatch_block_t
439 #undef _dispatch_Block_copy
441 _dispatch_Block_copy(dispatch_block_t db
)
443 dispatch_block_t rval
;
446 while (!fastpath(rval
= Block_copy(db
))) {
451 DISPATCH_CLIENT_CRASH("NULL was passed where a block should have been");
455 _dispatch_call_block_and_release(void *block
)
457 void (^b
)(void) = block
;
465 #pragma mark dispatch_client_callout
467 // Abort on uncaught exceptions thrown from client callouts rdar://8577499
468 #if DISPATCH_USE_CLIENT_CALLOUT && (__arm__ || !USE_OBJC)
469 // On platforms with SjLj exceptions, avoid the SjLj overhead on every callout
470 // by clearing the unwinder's TSD pointer to the handler stack around callouts
472 #define _dispatch_get_tsd_base()
473 #define _dispatch_get_unwind_tsd() (NULL)
474 #define _dispatch_set_unwind_tsd(u) do {(void)(u);} while (0)
475 #define _dispatch_free_unwind_tsd()
477 #undef _dispatch_client_callout
480 _dispatch_client_callout(void *ctxt
, dispatch_function_t f
)
482 _dispatch_get_tsd_base();
483 void *u
= _dispatch_get_unwind_tsd();
484 _dispatch_set_unwind_tsd(NULL
);
486 _dispatch_free_unwind_tsd();
487 _dispatch_set_unwind_tsd(u
);
490 #undef _dispatch_client_callout2
493 _dispatch_client_callout2(void *ctxt
, size_t i
, void (*f
)(void *, size_t))
495 _dispatch_get_tsd_base();
496 void *u
= _dispatch_get_unwind_tsd();
497 _dispatch_set_unwind_tsd(NULL
);
499 _dispatch_free_unwind_tsd();
500 _dispatch_set_unwind_tsd(u
);
503 #endif // DISPATCH_USE_CLIENT_CALLOUT
506 #pragma mark _os_object_t no_objc
510 static const _os_object_class_s _os_object_class
;
513 _os_object_init(void)
519 _os_object_alloc(const void *cls
, size_t size
)
522 dispatch_assert(size
>= sizeof(struct _os_object_s
));
523 if (!cls
) cls
= &_os_object_class
;
524 while (!fastpath(obj
= calloc(1u, size
))) {
525 sleep(1); // Temporary resource shortage
527 obj
->os_obj_isa
= cls
;
532 _os_object_dealloc(_os_object_t obj
)
534 *((void *volatile*)&obj
->os_obj_isa
) = (void *)0x200;
539 _os_object_xref_dispose(_os_object_t obj
)
541 if (fastpath(obj
->os_obj_isa
->_os_obj_xref_dispose
)) {
542 return obj
->os_obj_isa
->_os_obj_xref_dispose(obj
);
544 return _os_object_release_internal(obj
);
548 _os_object_dispose(_os_object_t obj
)
550 if (fastpath(obj
->os_obj_isa
->_os_obj_dispose
)) {
551 return obj
->os_obj_isa
->_os_obj_dispose(obj
);
553 return _os_object_dealloc(obj
);
557 #pragma mark dispatch_autorelease_pool no_objc
559 #if DISPATCH_COCOA_COMPAT
561 void *_dispatch_autorelease_pool_push(void) {
563 if (_dispatch_begin_NSAutoReleasePool
) {
564 pool
= _dispatch_begin_NSAutoReleasePool();
569 void _dispatch_autorelease_pool_pop(void *pool
) {
570 if (_dispatch_end_NSAutoReleasePool
) {
571 _dispatch_end_NSAutoReleasePool(pool
);
575 #endif // DISPATCH_COCOA_COMPAT
579 #pragma mark dispatch_source_types
582 dispatch_source_type_timer_init(dispatch_source_t ds
,
583 dispatch_source_type_t type DISPATCH_UNUSED
,
584 uintptr_t handle DISPATCH_UNUSED
,
586 dispatch_queue_t q DISPATCH_UNUSED
)
588 ds
->ds_refs
= calloc(1ul, sizeof(struct dispatch_timer_source_refs_s
));
589 if (slowpath(!ds
->ds_refs
)) return;
590 ds
->ds_needs_rearm
= true;
591 ds
->ds_is_timer
= true;
592 ds_timer(ds
->ds_refs
).flags
= mask
;
595 const struct dispatch_source_type_s _dispatch_source_type_timer
= {
597 .filter
= DISPATCH_EVFILT_TIMER
,
599 .mask
= DISPATCH_TIMER_WALL_CLOCK
,
600 .init
= dispatch_source_type_timer_init
,
603 const struct dispatch_source_type_s _dispatch_source_type_read
= {
605 .filter
= EVFILT_READ
,
606 .flags
= EV_DISPATCH
,
610 const struct dispatch_source_type_s _dispatch_source_type_write
= {
612 .filter
= EVFILT_WRITE
,
613 .flags
= EV_DISPATCH
,
617 #if DISPATCH_USE_VM_PRESSURE
618 #if TARGET_IPHONE_SIMULATOR // rdar://problem/9219483
619 static int _dispatch_ios_simulator_memory_warnings_fd
= -1;
621 _dispatch_ios_simulator_vm_source_init(void *context DISPATCH_UNUSED
)
623 char *e
= getenv("IPHONE_SIMULATOR_MEMORY_WARNINGS");
625 _dispatch_ios_simulator_memory_warnings_fd
= open(e
, O_EVTONLY
);
626 if (_dispatch_ios_simulator_memory_warnings_fd
== -1) {
627 (void)dispatch_assume_zero(errno
);
631 dispatch_source_type_vm_init(dispatch_source_t ds
,
632 dispatch_source_type_t type DISPATCH_UNUSED
,
633 uintptr_t handle DISPATCH_UNUSED
,
635 dispatch_queue_t q DISPATCH_UNUSED
)
637 static dispatch_once_t pred
;
638 dispatch_once_f(&pred
, NULL
, _dispatch_ios_simulator_vm_source_init
);
639 ds
->ds_dkev
->dk_kevent
.ident
= (mask
& DISPATCH_VM_PRESSURE
?
640 _dispatch_ios_simulator_memory_warnings_fd
: -1);
643 const struct dispatch_source_type_s _dispatch_source_type_vm
= {
645 .filter
= EVFILT_VNODE
,
649 .init
= dispatch_source_type_vm_init
,
653 dispatch_source_type_vm_init(dispatch_source_t ds
,
654 dispatch_source_type_t type DISPATCH_UNUSED
,
655 uintptr_t handle DISPATCH_UNUSED
,
656 unsigned long mask DISPATCH_UNUSED
,
657 dispatch_queue_t q DISPATCH_UNUSED
)
659 ds
->ds_is_level
= false;
662 const struct dispatch_source_type_s _dispatch_source_type_vm
= {
665 .flags
= EV_DISPATCH
,
667 .mask
= NOTE_VM_PRESSURE
,
668 .init
= dispatch_source_type_vm_init
,
673 const struct dispatch_source_type_s _dispatch_source_type_proc
= {
675 .filter
= EVFILT_PROC
,
678 .mask
= NOTE_EXIT
|NOTE_FORK
|NOTE_EXEC
679 #if HAVE_DECL_NOTE_SIGNAL
682 #if HAVE_DECL_NOTE_REAP
688 const struct dispatch_source_type_s _dispatch_source_type_signal
= {
690 .filter
= EVFILT_SIGNAL
,
694 const struct dispatch_source_type_s _dispatch_source_type_vnode
= {
696 .filter
= EVFILT_VNODE
,
699 .mask
= NOTE_DELETE
|NOTE_WRITE
|NOTE_EXTEND
|NOTE_ATTRIB
|NOTE_LINK
|
700 NOTE_RENAME
|NOTE_REVOKE
701 #if HAVE_DECL_NOTE_NONE
707 const struct dispatch_source_type_s _dispatch_source_type_vfs
= {
712 .mask
= VQ_NOTRESP
|VQ_NEEDAUTH
|VQ_LOWDISK
|VQ_MOUNT
|VQ_UNMOUNT
|VQ_DEAD
|
713 VQ_ASSIST
|VQ_NOTRESPLOCK
714 #if HAVE_DECL_VQ_UPDATE
717 #if HAVE_DECL_VQ_VERYLOWDISK
723 const struct dispatch_source_type_s _dispatch_source_type_data_add
= {
725 .filter
= DISPATCH_EVFILT_CUSTOM_ADD
,
729 const struct dispatch_source_type_s _dispatch_source_type_data_or
= {
731 .filter
= DISPATCH_EVFILT_CUSTOM_OR
,
740 dispatch_source_type_mach_send_init(dispatch_source_t ds
,
741 dispatch_source_type_t type DISPATCH_UNUSED
,
742 uintptr_t handle DISPATCH_UNUSED
, unsigned long mask
,
743 dispatch_queue_t q DISPATCH_UNUSED
)
745 static dispatch_once_t pred
;
746 dispatch_once_f(&pred
, NULL
, _dispatch_mach_notify_source_init
);
748 // Preserve legacy behavior that (mask == 0) => DISPATCH_MACH_SEND_DEAD
749 ds
->ds_dkev
->dk_kevent
.fflags
= DISPATCH_MACH_SEND_DEAD
;
750 ds
->ds_pending_data_mask
= DISPATCH_MACH_SEND_DEAD
;
754 const struct dispatch_source_type_s _dispatch_source_type_mach_send
= {
756 .filter
= EVFILT_MACHPORT
,
759 .mask
= DISPATCH_MACH_SEND_DEAD
|DISPATCH_MACH_SEND_POSSIBLE
,
760 .init
= dispatch_source_type_mach_send_init
,
764 dispatch_source_type_mach_recv_init(dispatch_source_t ds
,
765 dispatch_source_type_t type DISPATCH_UNUSED
,
766 uintptr_t handle DISPATCH_UNUSED
,
767 unsigned long mask DISPATCH_UNUSED
,
768 dispatch_queue_t q DISPATCH_UNUSED
)
770 ds
->ds_is_level
= false;
773 const struct dispatch_source_type_s _dispatch_source_type_mach_recv
= {
775 .filter
= EVFILT_MACHPORT
,
776 .flags
= EV_DISPATCH
,
777 .fflags
= DISPATCH_MACH_RECV_MESSAGE
,
779 .init
= dispatch_source_type_mach_recv_init
,
782 const struct dispatch_source_type_s _dispatch_source_type_sock
= {
785 .filter
= EVFILT_SOCK
,
788 .mask
= NOTE_CONNRESET
| NOTE_READCLOSED
| NOTE_WRITECLOSED
|
789 NOTE_TIMEOUT
| NOTE_NOSRCADDR
| NOTE_IFDENIED
| NOTE_SUSPEND
|
790 NOTE_RESUME
| NOTE_KEEPALIVE
,
795 #pragma mark dispatch_mig
798 dispatch_mach_msg_get_context(mach_msg_header_t
*msg
)
800 mach_msg_context_trailer_t
*tp
;
801 void *context
= NULL
;
803 tp
= (mach_msg_context_trailer_t
*)((uint8_t *)msg
+
804 round_msg(msg
->msgh_size
));
805 if (tp
->msgh_trailer_size
>=
806 (mach_msg_size_t
)sizeof(mach_msg_context_trailer_t
)) {
807 context
= (void *)(uintptr_t)tp
->msgh_context
;
813 _dispatch_wakeup_main_thread(mach_port_t mp DISPATCH_UNUSED
)
815 // dummy function just to pop out the main thread out of mach_msg()
820 _dispatch_consume_send_once_right(mach_port_t mp DISPATCH_UNUSED
)
822 // dummy function to consume a send-once right
827 _dispatch_mach_notify_port_destroyed(mach_port_t notify DISPATCH_UNUSED
,
831 // this function should never be called
832 (void)dispatch_assume_zero(name
);
833 kr
= mach_port_mod_refs(mach_task_self(), name
, MACH_PORT_RIGHT_RECEIVE
,-1);
834 DISPATCH_VERIFY_MIG(kr
);
835 (void)dispatch_assume_zero(kr
);
840 _dispatch_mach_notify_no_senders(mach_port_t notify
,
841 mach_port_mscount_t mscnt DISPATCH_UNUSED
)
843 // this function should never be called
844 (void)dispatch_assume_zero(notify
);
849 _dispatch_mach_notify_send_once(mach_port_t notify DISPATCH_UNUSED
)
851 // we only register for dead-name notifications
852 // some code deallocated our send-once right without consuming it
854 _dispatch_log("Corruption: An app/library deleted a libdispatch "
855 "dead-name notification");