Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fileprivate class _Lock {
private let underlying: UnsafeMutablePointer<os_unfair_lock>
#elseif os(Windows)
private let underlying: UnsafeMutablePointer<SRWLOCK>
#elseif os(WASI)
#elseif os(WASI) || os(Emscripten)
// pthread is currently not available on WASI
#elseif os(Cygwin) || os(FreeBSD) || os(OpenBSD)
private let underlying: UnsafeMutablePointer<pthread_mutex_t?>
Expand All @@ -259,7 +259,7 @@ fileprivate class _Lock {
#elseif os(Windows)
unsafe self.underlying = UnsafeMutablePointer.allocate(capacity: 1)
unsafe InitializeSRWLock(self.underlying)
#elseif os(WASI)
#elseif os(WASI) || os(Emscripten)
// WASI environment has only a single thread
#else
unsafe self.underlying = UnsafeMutablePointer.allocate(capacity: 1)
Expand All @@ -274,15 +274,15 @@ fileprivate class _Lock {
// `os_unfair_lock`s do not need to be explicitly destroyed
#elseif os(Windows)
// `SRWLOCK`s do not need to be explicitly destroyed
#elseif os(WASI)
#elseif os(WASI) || os(Emscripten)
// WASI environment has only a single thread
#else
guard unsafe pthread_mutex_destroy(self.underlying) == 0 else {
fatalError("pthread_mutex_destroy failed")
}
#endif

#if !os(WASI)
#if !os(WASI) && !os(Emscripten)
unsafe self.underlying.deinitialize(count: 1)
unsafe self.underlying.deallocate()
#endif
Expand All @@ -295,7 +295,7 @@ fileprivate class _Lock {
unsafe os_unfair_lock_lock(self.underlying)
#elseif os(Windows)
unsafe AcquireSRWLockExclusive(self.underlying)
#elseif os(WASI)
#elseif os(WASI) || os(Emscripten)
// WASI environment has only a single thread
#else
guard unsafe pthread_mutex_lock(self.underlying) == 0 else {
Expand All @@ -308,7 +308,7 @@ fileprivate class _Lock {
unsafe os_unfair_lock_unlock(self.underlying)
#elseif os(Windows)
unsafe ReleaseSRWLockExclusive(self.underlying)
#elseif os(WASI)
#elseif os(WASI) || os(Emscripten)
// WASI environment has only a single thread
#else
guard unsafe pthread_mutex_unlock(self.underlying) == 0 else {
Expand Down