From 7a87fa5cbca3eb4cacc8243eafbf86d41a12aba2 Mon Sep 17 00:00:00 2001 From: 3405691582 Date: Wed, 16 Apr 2025 22:20:16 -0400 Subject: [PATCH] Add a platform executor module for OpenBSD. This is basically the same as the one for Linux, but it would be somewhat awkward to add the platform conditional on a file named for Linux when OpenBSD is not Linux. Important note: if Dispatch is disabled, then this will cause a compilation error (probably not just for OpenBSD either), because PlatformExecutorFactory is both defined in PlatformExecutorNone.swift and PlatformExecutor<...>.swift in this case. Because this only bites OpenBSD bootstrap builds, and since OpenBSD support has been upstreamed to Dispatch, default to the Dispatch implementation for now to get this in, and we'll refactor in a different pr. --- Runtimes/Core/Concurrency/CMakeLists.txt | 1 + stdlib/public/Concurrency/CMakeLists.txt | 1 + .../Concurrency/PlatformExecutorOpenBSD.swift | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 stdlib/public/Concurrency/PlatformExecutorOpenBSD.swift diff --git a/Runtimes/Core/Concurrency/CMakeLists.txt b/Runtimes/Core/Concurrency/CMakeLists.txt index b4e90e1f9b2cf..65f9ca7ea92ed 100644 --- a/Runtimes/Core/Concurrency/CMakeLists.txt +++ b/Runtimes/Core/Concurrency/CMakeLists.txt @@ -82,6 +82,7 @@ add_library(swift_Concurrency PlatformExecutorDarwin.swift PlatformExecutorLinux.swift PlatformExecutorFreeBSD.swift + PlatformExecutorOpenBSD.swift PlatformExecutorWindows.swift PriorityQueue.swift SourceCompatibilityShims.swift diff --git a/stdlib/public/Concurrency/CMakeLists.txt b/stdlib/public/Concurrency/CMakeLists.txt index 66c9cb82b36df..611c525e6e666 100644 --- a/stdlib/public/Concurrency/CMakeLists.txt +++ b/stdlib/public/Concurrency/CMakeLists.txt @@ -164,6 +164,7 @@ set(SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES PlatformExecutorDarwin.swift PlatformExecutorLinux.swift PlatformExecutorWindows.swift + PlatformExecutorOpenBSD.swift PlatformExecutorFreeBSD.swift ) diff --git a/stdlib/public/Concurrency/PlatformExecutorOpenBSD.swift b/stdlib/public/Concurrency/PlatformExecutorOpenBSD.swift new file mode 100644 index 0000000000000..4bd2db9d5ebdc --- /dev/null +++ b/stdlib/public/Concurrency/PlatformExecutorOpenBSD.swift @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#if !$Embedded && os(OpenBSD) + +import Swift + +// The default executors for now are Dispatch-based +@available(SwiftStdlib 6.2, *) +public struct PlatformExecutorFactory: ExecutorFactory { + public static let mainExecutor: any MainExecutor = DispatchMainExecutor() + public static let defaultExecutor: any TaskExecutor + = DispatchGlobalTaskExecutor() +} + +#endif