mirror of
https://github.com/darlinghq/darling-libdispatch.git
synced 2024-11-26 21:40:24 +00:00
Restore Darling specific changes
This commit is contained in:
parent
4ae5219973
commit
342a5fcd4e
@ -65,7 +65,7 @@
|
||||
#elif TARGET_OS_MAC && !TARGET_OS_IPHONE
|
||||
# if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
|
||||
# elif defined(__i386__) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12
|
||||
# elif defined(__i386__) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12 && !defined(DARLING)
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
|
||||
# else
|
||||
# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
|
||||
|
@ -73,7 +73,7 @@
|
||||
int volatile ref_cnt; \
|
||||
int volatile xref_cnt
|
||||
|
||||
#if OS_OBJECT_HAVE_OBJC_SUPPORT
|
||||
#if OS_OBJECT_HAVE_OBJC_SUPPORT || defined(DARLING)
|
||||
#define OS_OBJECT_CLASS_SYMBOL(name) OS_##name##_class
|
||||
#if TARGET_OS_MAC && !TARGET_OS_SIMULATOR && defined(__i386__)
|
||||
#define OS_OBJECT_HAVE_OBJC1 1
|
||||
|
@ -1978,9 +1978,17 @@ DISPATCH_ALWAYS_INLINE DISPATCH_CONST
|
||||
static inline dispatch_queue_global_t
|
||||
_dispatch_get_root_queue(dispatch_qos_t qos, bool overcommit)
|
||||
{
|
||||
#ifdef DARLING
|
||||
if (qos == 0) {
|
||||
// !!! HACK !!!
|
||||
// treat QoS `0` as the manager queue
|
||||
return &_dispatch_mgr_root_queue;
|
||||
}
|
||||
#else
|
||||
if (unlikely(qos < DISPATCH_QOS_MIN || qos > DISPATCH_QOS_MAX)) {
|
||||
DISPATCH_CLIENT_CRASH(qos, "Corrupted priority");
|
||||
}
|
||||
#endif
|
||||
return &_dispatch_root_queues[2 * (qos - 1) + overcommit];
|
||||
}
|
||||
|
||||
|
@ -471,6 +471,8 @@ DISPATCH_UNAVAILABLE_INIT()
|
||||
@end
|
||||
|
||||
|
||||
// Darling-only conditional; the upstream sources don't have this conditional (but they should)
|
||||
#if defined(DARLING) && VOUCHER_USE_MACH_VOUCHER
|
||||
#pragma mark vouchers
|
||||
|
||||
OS_OBJECT_NONLAZY_CLASS
|
||||
@ -502,6 +504,7 @@ DISPATCH_UNAVAILABLE_INIT()
|
||||
}
|
||||
|
||||
@end
|
||||
#endif // defined(DARLING) && VOUCHER_USE_MACH_VOUCHER
|
||||
|
||||
#if VOUCHER_ENABLE_RECIPE_OBJECTS
|
||||
OS_OBJECT_NONLAZY_CLASS
|
||||
|
@ -7774,10 +7774,12 @@ _dispatch_root_queues_init_once(void *context DISPATCH_UNUSED)
|
||||
int wq_supported = _pthread_workqueue_supported();
|
||||
int r = ENOTSUP;
|
||||
|
||||
#ifndef DARLING
|
||||
if (!(wq_supported & WORKQ_FEATURE_MAINTENANCE)) {
|
||||
DISPATCH_INTERNAL_CRASH(wq_supported,
|
||||
"QoS Maintenance support required");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DISPATCH_USE_KEVENT_SETUP
|
||||
struct pthread_workqueue_config cfg = {
|
||||
|
@ -457,6 +457,19 @@ typedef struct dispatch_queue_specific_head_s {
|
||||
TAILQ_HEAD(, dispatch_queue_specific_s) dqsh_entries;
|
||||
} *dispatch_queue_specific_head_t;
|
||||
|
||||
#ifdef DARLING
|
||||
// for Darling, we move this up here because otherwise it's an undefined type when it's used in `dispatch_workloop_attr_s`
|
||||
//
|
||||
// it really makes me wonder: does Apple even try compiling their own code? because i don't know any C compiler
|
||||
// that accepts a type being used before it's `typedef`ed
|
||||
typedef struct dispatch_pthread_root_queue_observer_hooks_s {
|
||||
void (*queue_will_execute)(dispatch_queue_t queue);
|
||||
void (*queue_did_execute)(dispatch_queue_t queue);
|
||||
} dispatch_pthread_root_queue_observer_hooks_s;
|
||||
typedef dispatch_pthread_root_queue_observer_hooks_s
|
||||
*dispatch_pthread_root_queue_observer_hooks_t;
|
||||
#endif // DARLING
|
||||
|
||||
#define DISPATCH_WORKLOOP_ATTR_HAS_SCHED 0x0001u
|
||||
#define DISPATCH_WORKLOOP_ATTR_HAS_POLICY 0x0002u
|
||||
#define DISPATCH_WORKLOOP_ATTR_HAS_CPUPERCENT 0x0004u
|
||||
@ -651,12 +664,14 @@ struct dispatch_queue_global_s {
|
||||
} DISPATCH_CACHELINE_ALIGN;
|
||||
|
||||
|
||||
#ifndef DARLING
|
||||
typedef struct dispatch_pthread_root_queue_observer_hooks_s {
|
||||
void (*queue_will_execute)(dispatch_queue_t queue);
|
||||
void (*queue_did_execute)(dispatch_queue_t queue);
|
||||
} dispatch_pthread_root_queue_observer_hooks_s;
|
||||
typedef dispatch_pthread_root_queue_observer_hooks_s
|
||||
*dispatch_pthread_root_queue_observer_hooks_t;
|
||||
#endif // DARLING
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define DISPATCH_IOHID_SPI 1
|
||||
|
@ -936,11 +936,20 @@ _dispatch_source_invoke(dispatch_source_t ds, dispatch_invoke_context_t dic,
|
||||
#if DISPATCH_EVENT_BACKEND_KEVENT
|
||||
if (flags & DISPATCH_INVOKE_WORKLOOP_DRAIN) {
|
||||
dispatch_workloop_t dwl = (dispatch_workloop_t)_dispatch_get_wlh();
|
||||
#ifdef DARLING
|
||||
// HACK: this is almost certainly wrong, but i don't see why WLH_ANON is being returned
|
||||
if (dwl == DISPATCH_WLH_ANON) {
|
||||
_dispatch_event_loop_drain_anon_timers();
|
||||
} else {
|
||||
#endif
|
||||
dispatch_timer_heap_t dth = dwl->dwl_timer_heap;
|
||||
if (dth && dth[0].dth_dirty_bits) {
|
||||
_dispatch_event_loop_drain_timers(dwl->dwl_timer_heap,
|
||||
DISPATCH_TIMER_WLH_COUNT);
|
||||
}
|
||||
#ifdef DARLING
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // DISPATCH_EVENT_BACKEND_KEVENT
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user