Skip to content

Commit 940db1b

Browse files
committed
stdlib: remove pthread_attr_t from _stdlib_pthread_create_block
The attributes were not being used currently. Since this is a private interface, remove the parameter as it makes it easier to port to Windows.
1 parent 82360c6 commit 940db1b

File tree

4 files changed

+7
-17
lines changed

4 files changed

+7
-17
lines changed

stdlib/private/StdlibUnittest/RaceTest.swift

+3-6
Original file line numberDiff line numberDiff line change
@@ -605,24 +605,21 @@ public func runRaceTest<RT : RaceTestWithPerTrialData>(
605605

606606
// Create the master thread.
607607
do {
608-
let (ret, tid) = _stdlib_pthread_create_block(
609-
nil, masterThreadBody, ())
608+
let (ret, tid) = _stdlib_pthread_create_block(masterThreadBody, ())
610609
expectEqual(0, ret)
611610
testTids.append(tid!)
612611
}
613612

614613
// Create racing threads.
615614
for i in 0..<racingThreadCount {
616-
let (ret, tid) = _stdlib_pthread_create_block(
617-
nil, racingThreadBody, i)
615+
let (ret, tid) = _stdlib_pthread_create_block(racingThreadBody, i)
618616
expectEqual(0, ret)
619617
testTids.append(tid!)
620618
}
621619

622620
// Create the alarm thread that enforces the timeout.
623621
do {
624-
let (ret, tid) = _stdlib_pthread_create_block(
625-
nil, alarmThreadBody, ())
622+
let (ret, tid) = _stdlib_pthread_create_block(alarmThreadBody, ())
626623
expectEqual(0, ret)
627624
alarmTid = tid!
628625
}

stdlib/private/SwiftPrivateThreadExtras/SwiftPrivateThreadExtras.swift

+1-8
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,8 @@ internal func invokeBlockContext(
5959
return context.run()
6060
}
6161

62-
#if os(Cygwin) || os(FreeBSD) || os(Haiku)
63-
public typealias _stdlib_pthread_attr_t = UnsafePointer<pthread_attr_t?>
64-
#else
65-
public typealias _stdlib_pthread_attr_t = UnsafePointer<pthread_attr_t>
66-
#endif
67-
6862
/// Block-based wrapper for `pthread_create`.
6963
public func _stdlib_pthread_create_block<Argument, Result>(
70-
_ attr: _stdlib_pthread_attr_t?,
7164
_ start_routine: @escaping (Argument) -> Result,
7265
_ arg: Argument
7366
) -> (CInt, pthread_t?) {
@@ -77,7 +70,7 @@ public func _stdlib_pthread_create_block<Argument, Result>(
7770
let contextAsVoidPointer = Unmanaged.passRetained(context).toOpaque()
7871

7972
var threadID = _make_pthread_t()
80-
let result = pthread_create(&threadID, attr,
73+
let result = pthread_create(&threadID, nil,
8174
{ invokeBlockContext($0) }, contextAsVoidPointer)
8275
if result == 0 {
8376
return (result, threadID)

test/Interpreter/enforce_exclusive_access.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ ExclusiveAccessTestSuite.test("ClosureCaptureReadRead") {
120120
// have overlapping accesses
121121
ExclusiveAccessTestSuite.test("PerThreadEnforcement") {
122122
modifyAndPerform(&globalX) {
123-
let (_, otherThread) = _stdlib_pthread_create_block(nil, { (_ : Void) -> () in
123+
let (_, otherThread) = _stdlib_pthread_create_block({ (_ : Void) -> () in
124124
globalX.i = 12 // no-trap
125125
return ()
126126
}, ())

validation-test/stdlib/StringSlicesConcurrentAppend.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ StringTestSuite.test("SliceConcurrentAppend") {
9494
expectEqual(0, ret)
9595

9696
let (createRet1, tid1) = _stdlib_pthread_create_block(
97-
nil, sliceConcurrentAppendThread, .Primary)
97+
sliceConcurrentAppendThread, .Primary)
9898
let (createRet2, tid2) = _stdlib_pthread_create_block(
99-
nil, sliceConcurrentAppendThread, .Secondary)
99+
sliceConcurrentAppendThread, .Secondary)
100100

101101
expectEqual(0, createRet1)
102102
expectEqual(0, createRet2)

0 commit comments

Comments
 (0)