Skip to content

Commit 6814f43

Browse files
authored
Fix the Linux build using the 5.10 toolchain. (#362)
`@_extern(c)` is new in 6.0, so let's just declare `pthread_setname_np()` in Stubs.h. See https://ci.swift.org/job/swift-testing-main-swift-5.10-linux/204/console for more information on the build failure. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 74c4286 commit 6814f43

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Sources/Testing/ExitTests/WaitFor.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ private let _waitThreadNoChildrenCondition = {
4646
return UncheckedSendable(rawValue: result)
4747
}()
4848

49-
#if os(Linux)
50-
/// Set the name of the current thread.
51-
///
52-
/// This function declaration is provided because `pthread_setname_np()` is
53-
/// only declared if `_GNU_SOURCE` is set, but setting it causes build errors
54-
/// due to conflicts with Swift's Glibc module.
55-
@_extern(c) func pthread_setname_np(_: pthread_t, _: UnsafePointer<CChar>) -> CInt
56-
#endif
57-
5849
/// The implementation of `_createWaitThread()`, run only once.
5950
private let _createWaitThreadImpl: Void = {
6051
// The body of the thread's run loop.

Sources/TestingInternals/include/Stubs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ SWT_EXTERN char *_Nullable *_Null_unspecified environ;
8888
static char *_Nullable *_Null_unspecified swt_environ(void) {
8989
return environ;
9090
}
91+
92+
/// Set the name of the current thread.
93+
///
94+
/// This function declaration is provided because `pthread_setname_np()` is
95+
/// only declared if `_GNU_SOURCE` is set, but setting it causes build errors
96+
/// due to conflicts with Swift's Glibc module.
97+
SWT_IMPORT_FROM_STDLIB int pthread_setname_np(pthread_t, const char *);
9198
#endif
9299

93100
#if __has_include(<signal.h>) && defined(si_pid)

0 commit comments

Comments
 (0)