Skip to content

Commit 79f7b63

Browse files
committed
FreeBSD: Testing: pthread handling
Fixing pthread usage in tsan and tsan-inout tests. pthreads are imported as opaque pointers on FreeBDS, and thus need to be kept in an optional pthread_t, like on Apple platforms. Unlike on macOS, pthread_join is not annotated with nullability annotations and thus takes an optional opaque pointer, so we don't need to unwrap it.
1 parent 3316e82 commit 79f7b63

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

test/Sanitizers/tsan/tsan.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var racey_x: Int;
5050

5151
// TSan %deflake as part of the test.
5252
for _ in 1...5 {
53-
#if os(macOS) || os(iOS)
53+
#if os(macOS) || os(iOS) || os(FreeBSD)
5454
var t : pthread_t?
5555
#else
5656
var t : pthread_t = 0
@@ -61,7 +61,7 @@ for _ in 1...5 {
6161

6262
return nil
6363
}, nil)
64-
#if os(macOS) || os(iOS)
64+
#if os(macOS) || os(iOS) || os(FreeBSD)
6565
threads.append(t!)
6666
#else
6767
threads.append(t)

validation-test/Sanitizers/tsan-inout.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var gInThread2: () -> () = { }
2727
// Spawn two threads, run the two passed in closures simultaneously, and
2828
// join them.
2929
func testRace(name: String, thread inThread1: @escaping () -> (), thread inThread2: @escaping () -> ()) {
30-
#if canImport(Darwin)
30+
#if canImport(Darwin) || os(FreeBSD)
3131
var thread1: pthread_t?
3232
var thread2: pthread_t?
3333
#else

0 commit comments

Comments
 (0)