Skip to content

Commit 31df4ed

Browse files
committed
[Concurrency] Add a test for the new custom executor feature.
Added an executor implementation and a test that tries to use it. Also fix up a few issues in `ExecutorImpl.h`. rdar://135380149
1 parent 4ef4305 commit 31df4ed

File tree

3 files changed

+413
-7
lines changed

3 files changed

+413
-7
lines changed

stdlib/public/Concurrency/ExecutorImpl.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#endif
3333

3434
#include <inttypes.h>
35-
#include <stdalign.h>
3635
#include <stdbool.h>
3736
#include <stdlib.h>
3837

@@ -92,11 +91,11 @@ static inline int swift_priority_getBucketIndex(SwiftJobPriority priority) {
9291

9392
/// Used by the Concurrency runtime to represent a job. The `schedulerPrivate`
9493
/// field may be freely used by the executor implementation.
95-
typedef struct alignas(2 * alignof(void *)) {
94+
typedef struct {
9695
SwiftHeapMetadata const *__ptrauth_objc_isa_pointer metadata;
9796
void *schedulerPrivate[2];
9897
SwiftJobFlags flags;
99-
} SwiftJob;
98+
} __attribute__((aligned(2 * sizeof(void *)))) SwiftJob;
10099

101100
/// Indexes in the schedulerPrivate array
102101
enum {
@@ -173,7 +172,7 @@ swift_executor_complexEquality(SwiftHeapObject *identity,
173172
/// Get the type of executor (ordinary vs complex equality).
174173
static inline SwiftExecutorKind
175174
swift_executor_getKind(SwiftExecutorRef executor) {
176-
const uintptr_t mask = ~uintptr_t(alignof(void *) - 1);
175+
const uintptr_t mask = ~(uintptr_t)(sizeof(void *) - 1);
177176
return executor.implementation & ~mask;
178177
}
179178

@@ -202,7 +201,7 @@ static inline bool swift_executor_hasWitnessTable(SwiftExecutorRef executor) {
202201
/// Retrieve the witness table of an executor.
203202
static inline const SwiftExecutorWitnessTable *
204203
swift_executor_getWitnessTable(SwiftExecutorRef executor) {
205-
const uintptr_t mask = ~uintptr_t(alignof(void *) - 1);
204+
const uintptr_t mask = ~(uintptr_t)(sizeof(void *) - 1);
206205
return (const SwiftExecutorWitnessTable *)(executor.implementation & mask);
207206
}
208207

@@ -277,15 +276,15 @@ SWIFT_CC(swift) void swift_task_enqueueMainExecutorImpl(SwiftJob *job);
277276
SWIFT_CC(swift) void swift_task_checkIsolatedImpl(SwiftExecutorRef executor);
278277

279278
/// Get a reference to the main executor.
280-
SWIFT_CC(swift) SwiftExecutorRef swift_task_getMainExecutorImpl();
279+
SWIFT_CC(swift) SwiftExecutorRef swift_task_getMainExecutorImpl(void);
281280

282281
/// Check if the specified executor is the main executor.
283282
SWIFT_CC(swift) bool swift_task_isMainExecutorImpl(SwiftExecutorRef executor);
284283

285284
/// Drain the main executor's queue, processing jobs enqueued on it; this
286285
/// should never return.
287286
SWIFT_RUNTIME_ATTRIBUTE_NORETURN SWIFT_CC(swift) void
288-
swift_task_asyncMainDrainQueueImpl();
287+
swift_task_asyncMainDrainQueueImpl(void);
289288

290289
/// Hand control of the current thread to the global executor until the
291290
/// condition function returns `true`. Support for this function is optional,

0 commit comments

Comments
 (0)