Skip to content

Commit d0ed6f6

Browse files
authored
Merge pull request #73945 from mikeash/dispatch-async-swift-job-no-dlsym
[Concurrency] Reference dispatch_async_swift_job directly when the header is available.
2 parents 74a4d3e + c396f75 commit d0ed6f6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

stdlib/public/Concurrency/DispatchGlobalExecutor.inc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
#endif
3434
#endif
3535

36+
#if __has_include(<dispatch/private.h>)
37+
#include <dispatch/private.h>
38+
#define SWIFT_CONCURRENCY_HAS_DISPATCH_PRIVATE 1
39+
#endif
40+
3641
// Ensure that Job's layout is compatible with what Dispatch expects.
3742
// Note: MinimalDispatchObjectHeader just has the fields we care about, it is
3843
// not complete and should not be used for anything other than these asserts.
@@ -89,7 +94,10 @@ static void initializeDispatchEnqueueFunc(dispatch_queue_t queue, void *obj,
8994
// Always fall back to plain dispatch_async_f for back-deployed concurrency.
9095
#if !defined(SWIFT_CONCURRENCY_BACK_DEPLOYMENT)
9196
if (runtime::environment::concurrencyEnableJobDispatchIntegration())
92-
#if defined(_WIN32)
97+
#if SWIFT_CONCURRENCY_HAS_DISPATCH_PRIVATE
98+
if (SWIFT_RUNTIME_WEAK_CHECK(dispatch_async_swift_job))
99+
func = SWIFT_RUNTIME_WEAK_USE(dispatch_async_swift_job);
100+
#elif defined(_WIN32)
93101
func = reinterpret_cast<dispatchEnqueueFuncType>(
94102
GetProcAddress(LoadLibraryW(L"dispatch.dll"),
95103
"dispatch_async_swift_job"));

0 commit comments

Comments
 (0)