Skip to content
Merged
Show file tree
Hide file tree
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 @@ -361,7 +361,7 @@ extension Event.HumanReadableOutputRecorder {
comments.append("Swift Standard Library Version: \(swiftStandardLibraryVersion)")
}
comments.append("Swift Compiler Version: \(swiftCompilerVersion)")
#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
#if os(Linux) && canImport(Glibc)
comments.append("GNU C Library Version: \(glibcVersion)")
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Testing/ExitTests/SpawnProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func spawnExecutable(
// standardized in POSIX.1-2024 (see https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_adddup2.html
// and https://www.austingroupbugs.net/view.php?id=411).
_ = posix_spawn_file_actions_adddup2(fileActions, fd, fd)
#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
#if os(Linux) && canImport(Glibc)
if _slowPath(glibcVersion < VersionNumber(2, 29)) {
// This system is using an older version of glibc that does not
// implement FD_CLOEXEC clearing in posix_spawn_file_actions_adddup2(),
Expand Down
4 changes: 0 additions & 4 deletions Sources/Testing/ExitTests/WaitFor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ private let _childProcessContinuations = LockedWith<pthread_mutex_t, [pid_t: Che
/// A condition variable used to suspend the waiter thread created by
/// `_createWaitThread()` when there are no child processes to await.
private nonisolated(unsafe) let _waitThreadNoChildrenCondition = {
#if os(FreeBSD) || os(OpenBSD)
let result = UnsafeMutablePointer<pthread_cond_t?>.allocate(capacity: 1)
#else
let result = UnsafeMutablePointer<pthread_cond_t>.allocate(capacity: 1)
#endif
_ = pthread_cond_init(result, nil)
return result
}()
Expand Down
5 changes: 3 additions & 2 deletions Sources/Testing/Support/Locked+Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ extension os_unfair_lock_s: Lockable {

#if os(FreeBSD) || os(OpenBSD)
typealias pthread_mutex_t = _TestingInternals.pthread_mutex_t?
typealias pthread_cond_t = _TestingInternals.pthread_cond_t?
#endif

#if SWT_TARGET_OS_APPLE || os(Linux) || os(Android) || (os(WASI) && _runtime(_multithreaded)) || os(FreeBSD) || os(OpenBSD)
#if SWT_TARGET_OS_APPLE || os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android) || (os(WASI) && _runtime(_multithreaded))
extension pthread_mutex_t: Lockable {
static func initializeLock(at lock: UnsafeMutablePointer<Self>) {
_ = pthread_mutex_init(lock, nil)
Expand Down Expand Up @@ -83,7 +84,7 @@ extension SRWLOCK: Lockable {

#if SWT_TARGET_OS_APPLE && !SWT_NO_OS_UNFAIR_LOCK
typealias DefaultLock = os_unfair_lock
#elseif SWT_TARGET_OS_APPLE || os(Linux) || os(Android) || (os(WASI) && _runtime(_multithreaded)) || os(FreeBSD) || os(OpenBSD)
#elseif SWT_TARGET_OS_APPLE || os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android) || (os(WASI) && _runtime(_multithreaded))
typealias DefaultLock = pthread_mutex_t
#elseif os(Windows)
typealias DefaultLock = SRWLOCK
Expand Down
2 changes: 1 addition & 1 deletion Sources/Testing/Support/Versions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ var swiftCompilerVersion: VersionNumber {
)
}

#if canImport(Glibc) && !os(FreeBSD) && !os(OpenBSD)
#if os(Linux) && canImport(Glibc)
/// The (runtime, not compile-time) version of glibc in use on this system.
///
/// This value is not part of the public interface of the testing library.
Expand Down
13 changes: 7 additions & 6 deletions Tests/TestingTests/ABIEntryPointTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ struct ABIEntryPointTests {
passing arguments: __CommandLineArguments_v0,
recordHandler: @escaping @Sendable (_ recordJSON: UnsafeRawBufferPointer) -> Void = { _ in }
) async throws -> Bool {
#if !os(Linux) && !os(FreeBSD) && !os(Android) && !SWT_NO_DYNAMIC_LINKING
#if !(os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android)) && !SWT_NO_DYNAMIC_LINKING
// Get the ABI entry point by dynamically looking it up at runtime.
//
// NOTE: The standard Linux linker does not allow exporting symbols from
// executables, so dlsym() does not let us find this function on that
// platform when built as an executable rather than a dynamic library.
// NOTE: The standard linkers on these platforms do not export symbols from
// executables, so dlsym() does not let us find this function on these
// platforms when built as an executable rather than a dynamic library.
let abiv0_getEntryPoint = try withTestingLibraryImageAddress { testingLibrary in
try #require(
symbol(in: testingLibrary, named: "swt_abiv0_getEntryPoint").map {
Expand Down Expand Up @@ -187,8 +187,9 @@ private func withTestingLibraryImageAddress<R>(_ body: (ImageAddress?) throws ->
defer {
dlclose(testingLibraryAddress)
}
#elseif os(Linux) || os(FreeBSD) || os(Android)
// When using glibc, dladdr() is only available if __USE_GNU is specified.
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android)
// We can't dynamically look up a function linked into the test executable on
// ELF-based platforms.
#elseif os(Windows)
let flags = DWORD(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)
try addressInTestingLibrary.withMemoryRebound(to: wchar_t.self, capacity: MemoryLayout<UnsafeRawPointer>.stride / MemoryLayout<wchar_t>.stride) { addressInTestingLibrary in
Expand Down