Skip to content

Commit a28a09c

Browse files
committed
dispatch: exclude workgroup support on non-Apple targets
Follow the advice from @MadCoder and limit workgroup headers to Apple targets only. This is required to restore the ability to build dispatch on other platforms.
1 parent 928576e commit a28a09c

File tree

6 files changed

+20
-1
lines changed

6 files changed

+20
-1
lines changed

dispatch/dispatch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
#endif
6363

6464
#include <os/object.h>
65+
#if HAVE_MACH
6566
#include <os/workgroup.h>
67+
#endif
6668
#include <dispatch/base.h>
6769
#include <dispatch/time.h>
6870
#include <dispatch/object.h>

dispatch/workloop.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void
133133
dispatch_workloop_set_autorelease_frequency(dispatch_workloop_t workloop,
134134
dispatch_autorelease_frequency_t frequency);
135135

136+
#if HAVE_MACH
136137
/*!
137138
* @function dispatch_workloop_set_os_workgroup
138139
*
@@ -159,6 +160,7 @@ DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
159160
void
160161
dispatch_workloop_set_os_workgroup(dispatch_workloop_t workloop,
161162
os_workgroup_t workgroup);
163+
#endif
162164

163165
__END_DECLS
164166

os/eventlink_private.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#ifndef __OS_EVENTLINK__
22
#define __OS_EVENTLINK__
33

4-
#include <os/object.h>
4+
#if HAVE_MACH
55
#include <mach/mach.h>
6+
#endif
7+
8+
#include <os/object.h>
69
#include <os/clock.h>
710

811
__BEGIN_DECLS

src/internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,12 @@ upcast(dispatch_object_t dou)
219219
#endif // __OBJC__
220220

221221
#include <os/object.h>
222+
#if HAVE_MACH
222223
#include <os/workgroup_base.h>
223224
#include <os/workgroup_object.h>
224225
#include <os/workgroup_interval.h>
225226
#include <os/workgroup_parallel.h>
227+
#endif
226228
#include <dispatch/time.h>
227229
#include <dispatch/object.h>
228230
#include <dispatch/queue.h>
@@ -241,8 +243,10 @@ upcast(dispatch_object_t dou)
241243
#endif
242244
#include "os/object_private.h"
243245
#include "os/eventlink_private.h"
246+
#if HAVE_MACH
244247
#include "os/workgroup_object_private.h"
245248
#include "os/workgroup_interval_private.h"
249+
#endif
246250
#include "apply_private.h"
247251
#include "queue_private.h"
248252
#include "channel_private.h"
@@ -1180,7 +1184,9 @@ extern bool _dispatch_kevent_workqueue_enabled;
11801184

11811185
/* #includes dependent on internal.h */
11821186
#include "object_internal.h"
1187+
#if HAVE_MACH
11831188
#include "workgroup_internal.h"
1189+
#endif
11841190
#include "eventlink_internal.h"
11851191
#include "semaphore_internal.h"
11861192
#include "introspection_internal.h"

src/queue.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,9 +4056,11 @@ static void
40564056
_dispatch_workloop_attributes_dispose(dispatch_workloop_t dwl)
40574057
{
40584058
if (dwl->dwl_attr) {
4059+
#if HAVE_MACH
40594060
if (dwl->dwl_attr->workgroup) {
40604061
_os_object_release(dwl->dwl_attr->workgroup->_as_os_obj);
40614062
}
4063+
#endif
40624064
free(dwl->dwl_attr);
40634065
}
40644066
}
@@ -4127,6 +4129,7 @@ dispatch_workloop_set_qos_class_floor(dispatch_workloop_t dwl,
41274129
#endif // TARGET_OS_MAC
41284130
}
41294131

4132+
#if HAVE_MACH
41304133
void
41314134
dispatch_workloop_set_os_workgroup(dispatch_workloop_t dwl, os_workgroup_t wg)
41324135
{
@@ -4142,6 +4145,7 @@ dispatch_workloop_set_os_workgroup(dispatch_workloop_t dwl, os_workgroup_t wg)
41424145
_os_object_retain(wg->_as_os_obj);
41434146
dwl->dwl_attr->workgroup = wg;
41444147
}
4148+
#endif
41454149

41464150
void
41474151
dispatch_workloop_set_qos_class(dispatch_workloop_t dwl,

src/queue_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ typedef struct dispatch_workloop_attr_s {
482482
uint8_t percent;
483483
uint32_t refillms;
484484
} dwla_cpupercent;
485+
#if HAVE_MACH
485486
os_workgroup_t workgroup;
487+
#endif
486488
dispatch_pthread_root_queue_observer_hooks_s dwla_observers;
487489
} dispatch_workloop_attr_s;
488490

0 commit comments

Comments
 (0)