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.
This commit is contained in:
Saleem Abdulrasool
2018-11-25 11:22:27 -08:00
parent 82360c6b27
commit 940db1b0cf
4 changed files with 7 additions and 17 deletions

View File

@@ -605,24 +605,21 @@ public func runRaceTest<RT : RaceTestWithPerTrialData>(
// Create the master thread.
do {
let (ret, tid) = _stdlib_pthread_create_block(
nil, masterThreadBody, ())
let (ret, tid) = _stdlib_pthread_create_block(masterThreadBody, ())
expectEqual(0, ret)
testTids.append(tid!)
}
// Create racing threads.
for i in 0..<racingThreadCount {
let (ret, tid) = _stdlib_pthread_create_block(
nil, racingThreadBody, i)
let (ret, tid) = _stdlib_pthread_create_block(racingThreadBody, i)
expectEqual(0, ret)
testTids.append(tid!)
}
// Create the alarm thread that enforces the timeout.
do {
let (ret, tid) = _stdlib_pthread_create_block(
nil, alarmThreadBody, ())
let (ret, tid) = _stdlib_pthread_create_block(alarmThreadBody, ())
expectEqual(0, ret)
alarmTid = tid!
}

View File

@@ -59,15 +59,8 @@ internal func invokeBlockContext(
return context.run()
}
#if os(Cygwin) || os(FreeBSD) || os(Haiku)
public typealias _stdlib_pthread_attr_t = UnsafePointer<pthread_attr_t?>
#else
public typealias _stdlib_pthread_attr_t = UnsafePointer<pthread_attr_t>
#endif
/// Block-based wrapper for `pthread_create`.
public func _stdlib_pthread_create_block<Argument, Result>(
_ attr: _stdlib_pthread_attr_t?,
_ start_routine: @escaping (Argument) -> Result,
_ arg: Argument
) -> (CInt, pthread_t?) {
@@ -77,7 +70,7 @@ public func _stdlib_pthread_create_block<Argument, Result>(
let contextAsVoidPointer = Unmanaged.passRetained(context).toOpaque()
var threadID = _make_pthread_t()
let result = pthread_create(&threadID, attr,
let result = pthread_create(&threadID, nil,
{ invokeBlockContext($0) }, contextAsVoidPointer)
if result == 0 {
return (result, threadID)

View File

@@ -120,7 +120,7 @@ ExclusiveAccessTestSuite.test("ClosureCaptureReadRead") {
// have overlapping accesses
ExclusiveAccessTestSuite.test("PerThreadEnforcement") {
modifyAndPerform(&globalX) {
let (_, otherThread) = _stdlib_pthread_create_block(nil, { (_ : Void) -> () in
let (_, otherThread) = _stdlib_pthread_create_block({ (_ : Void) -> () in
globalX.i = 12 // no-trap
return ()
}, ())

View File

@@ -94,9 +94,9 @@ StringTestSuite.test("SliceConcurrentAppend") {
expectEqual(0, ret)
let (createRet1, tid1) = _stdlib_pthread_create_block(
nil, sliceConcurrentAppendThread, .Primary)
sliceConcurrentAppendThread, .Primary)
let (createRet2, tid2) = _stdlib_pthread_create_block(
nil, sliceConcurrentAppendThread, .Secondary)
sliceConcurrentAppendThread, .Secondary)
expectEqual(0, createRet1)
expectEqual(0, createRet2)