Skip to content

Commit 2e3662d

Browse files
committed
[stdlib] Tweak callback for pthread_create to avoid signature issues. (#2245)
Use a wrapper closure to infer the correct argument and result type; continue using an IUO for the result type to allow implicit conversion.
1 parent aa34ace commit 2e3662d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ internal class PthreadBlockContextImpl<Argument, Result>: PthreadBlockContext {
4949

5050
/// Entry point for `pthread_create` that invokes a block context.
5151
internal func invokeBlockContext(
52-
_ contextAsVoidPointer: UnsafeMutablePointer<Void>!
52+
_ contextAsVoidPointer: UnsafeMutablePointer<Void>?
5353
) -> UnsafeMutablePointer<Void>! {
5454
// The context is passed in +1; we're responsible for releasing it.
5555
let contextAsOpaque = OpaquePointer(contextAsVoidPointer!)
@@ -73,7 +73,7 @@ public func _stdlib_pthread_create_block<Argument, Result>(
7373

7474
var threadID = _make_pthread_t()
7575
let result = pthread_create(&threadID, attr,
76-
invokeBlockContext, contextAsVoidPointer)
76+
{ invokeBlockContext($0) }, contextAsVoidPointer)
7777
if result == 0 {
7878
return (result, threadID)
7979
} else {

0 commit comments

Comments
 (0)