Skip to content

Commit 47b4c7e

Browse files
committed
fixed the pthread compilation errors by following Sangjin Han's advice,
see also Han's PR: https://github.com/apple/swift/pull/3886/files#diff-99fd89ad44c4466de8ad6b8aab9c207d
1 parent 7edc310 commit 47b4c7e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import Darwin
1616
import Glibc
1717
#endif
1818

19-
// FIXME: On FreeBSD, code in this file doesn't compile
20-
#if !os(FreeBSD)
2119
//
2220
// Implement pthread barriers.
2321
//
@@ -45,8 +43,13 @@ public var _stdlib_PTHREAD_BARRIER_SERIAL_THREAD: CInt {
4543
}
4644

4745
public struct _stdlib_pthread_barrier_t {
46+
#if CYGWIN || os(FreeBSD)
47+
var mutex: UnsafeMutablePointer<pthread_mutex_t?>? = nil
48+
var cond: UnsafeMutablePointer<pthread_cond_t?>? = nil
49+
#else
4850
var mutex: UnsafeMutablePointer<pthread_mutex_t>? = nil
4951
var cond: UnsafeMutablePointer<pthread_cond_t>? = nil
52+
#endif
5053

5154
/// The number of threads to synchronize.
5255
var count: CUnsignedInt = 0
@@ -131,4 +134,3 @@ public func _stdlib_pthread_barrier_wait(
131134
return _stdlib_PTHREAD_BARRIER_SERIAL_THREAD
132135
}
133136
}
134-
#endif

stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import Darwin
2121
import Glibc
2222
#endif
2323

24-
// FIXME: On FreeBSD, code in this file doesn't compile
25-
#if !os(FreeBSD)
2624
/// An abstract base class to encapsulate the context necessary to invoke
2725
/// a block from pthread_create.
2826
internal class PthreadBlockContext {
@@ -61,9 +59,15 @@ internal func invokeBlockContext(
6159
return context.run()
6260
}
6361

62+
#if CYGWIN || os(FreeBSD)
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+
6468
/// Block-based wrapper for `pthread_create`.
6569
public func _stdlib_pthread_create_block<Argument, Result>(
66-
_ attr: UnsafePointer<pthread_attr_t>?,
70+
_ attr: _stdlib_pthread_attr_t?,
6771
_ start_routine: @escaping (Argument) -> Result,
6872
_ arg: Argument
6973
) -> (CInt, pthread_t?) {
@@ -142,4 +146,3 @@ public class _stdlib_Barrier {
142146
}
143147
}
144148
}
145-
#endif

0 commit comments

Comments
 (0)