mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-22 04:10:40 +00:00
Add enable_wasm_sdk_build: true to pull_request.yml (#363)
`swift-async-algorithms` should be built for Wasm as one of the officially supported platforms on CI to prevent possible future regressions.
This commit is contained in:
1 parent
6dcb3acddd
commit
c537393339
3 files changed
+17
-9
No files matched your search
@@ -8,6 +8,10 @@ jobs:
|
||||
tests:
|
||||
name: Test
|
||||
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
|
||||
with:
|
||||
enable_wasm_sdk_build: true
|
||||
wasm_sdk_build_command: swift build -Xcc -D_WASI_EMULATED_PTHREAD
|
||||
|
||||
soundness:
|
||||
name: Soundness
|
||||
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
|
||||
|
||||
@@ -19,6 +19,8 @@ import Musl
|
||||
import WinSDK
|
||||
#elseif canImport(Bionic)
|
||||
import Bionic
|
||||
#elseif canImport(wasi_pthread)
|
||||
import wasi_pthread
|
||||
#else
|
||||
#error("Unsupported platform")
|
||||
#endif
|
||||
@@ -26,7 +28,7 @@ import Bionic
|
||||
internal struct Lock {
|
||||
#if canImport(Darwin)
|
||||
typealias Primitive = os_unfair_lock
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
|
||||
typealias Primitive = pthread_mutex_t
|
||||
#elseif canImport(WinSDK)
|
||||
typealias Primitive = SRWLOCK
|
||||
@@ -44,7 +46,7 @@ internal struct Lock {
|
||||
fileprivate static func initialize(_ platformLock: PlatformLock) {
|
||||
#if canImport(Darwin)
|
||||
platformLock.initialize(to: os_unfair_lock())
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
|
||||
let result = pthread_mutex_init(platformLock, nil)
|
||||
precondition(result == 0, "pthread_mutex_init failed")
|
||||
#elseif canImport(WinSDK)
|
||||
@@ -55,7 +57,7 @@ internal struct Lock {
|
||||
}
|
||||
|
||||
fileprivate static func deinitialize(_ platformLock: PlatformLock) {
|
||||
#if canImport(Glibc) || canImport(Musl) || canImport(Bionic)
|
||||
#if canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
|
||||
let result = pthread_mutex_destroy(platformLock)
|
||||
precondition(result == 0, "pthread_mutex_destroy failed")
|
||||
#endif
|
||||
@@ -65,7 +67,7 @@ internal struct Lock {
|
||||
fileprivate static func lock(_ platformLock: PlatformLock) {
|
||||
#if canImport(Darwin)
|
||||
os_unfair_lock_lock(platformLock)
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
|
||||
pthread_mutex_lock(platformLock)
|
||||
#elseif canImport(WinSDK)
|
||||
AcquireSRWLockExclusive(platformLock)
|
||||
@@ -77,7 +79,7 @@ internal struct Lock {
|
||||
fileprivate static func unlock(_ platformLock: PlatformLock) {
|
||||
#if canImport(Darwin)
|
||||
os_unfair_lock_unlock(platformLock)
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
|
||||
let result = pthread_mutex_unlock(platformLock)
|
||||
precondition(result == 0, "pthread_mutex_unlock failed")
|
||||
#elseif canImport(WinSDK)
|
||||
|
||||
@@ -19,6 +19,8 @@ import Glibc
|
||||
import Musl
|
||||
#elseif canImport(Bionic)
|
||||
import Bionic
|
||||
#elseif canImport(wasi_pthread)
|
||||
import wasi_pthread
|
||||
#elseif canImport(WinSDK)
|
||||
#error("TODO: Port TaskDriver threading to windows")
|
||||
#else
|
||||
@@ -31,7 +33,7 @@ func start_thread(_ raw: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? {
|
||||
Unmanaged<TaskDriver>.fromOpaque(raw).takeRetainedValue().run()
|
||||
return nil
|
||||
}
|
||||
#elseif (canImport(Glibc) && !os(Android)) || canImport(Musl)
|
||||
#elseif (canImport(Glibc) && !os(Android)) || canImport(Musl) || canImport(wasi_pthread)
|
||||
@available(AsyncAlgorithms 1.0, *)
|
||||
func start_thread(_ raw: UnsafeMutableRawPointer?) -> UnsafeMutableRawPointer? {
|
||||
Unmanaged<TaskDriver>.fromOpaque(raw!).takeRetainedValue().run()
|
||||
@@ -51,7 +53,7 @@ func start_thread(_ raw: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer {
|
||||
final class TaskDriver {
|
||||
let work: (TaskDriver) -> Void
|
||||
let queue: WorkQueue
|
||||
#if canImport(Darwin)
|
||||
#if canImport(Darwin) || canImport(wasi_pthread)
|
||||
var thread: pthread_t?
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
|
||||
var thread = pthread_t()
|
||||
@@ -65,7 +67,7 @@ final class TaskDriver {
|
||||
}
|
||||
|
||||
func start() {
|
||||
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic)
|
||||
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
|
||||
pthread_create(
|
||||
&thread,
|
||||
nil,
|
||||
@@ -85,7 +87,7 @@ final class TaskDriver {
|
||||
}
|
||||
|
||||
func join() {
|
||||
#if canImport(Darwin)
|
||||
#if canImport(Darwin) || canImport(wasi_pthread)
|
||||
pthread_join(thread!, nil)
|
||||
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
|
||||
pthread_join(thread, nil)
|
||||
|
||||
Reference in new issue
Block a user