Skip to content

Commit 85ce1cb

Browse files
committed
OpenBSD can makeProcessSource after all.
Unwind some conditionals hiding makeProcessSource and associated DispatchSourceProcess. We can probably makeFileSystemObjectSource too, but presumably since pid_t on OpenBSD is Int32, there is a protocol conflict with DispatchSourceProcess and DispatchSourceFileSystemObject. For now, just reveal DispatchSourceProcess.
1 parent ed4c2a1 commit 85ce1cb

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/swift/Source.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,27 @@ extension DispatchSource {
116116
}
117117
#endif
118118

119-
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
119+
#if !os(Linux) && !os(Android) && !os(Windows)
120120
public struct ProcessEvent : OptionSet, RawRepresentable {
121121
public let rawValue: UInt
122122
public init(rawValue: UInt) { self.rawValue = rawValue }
123123

124124
public static let exit = ProcessEvent(rawValue: 0x80000000)
125125
public static let fork = ProcessEvent(rawValue: 0x40000000)
126126
public static let exec = ProcessEvent(rawValue: 0x20000000)
127-
#if os(FreeBSD)
128-
public static let track = ProcessEvent(rawValue: 0x00000001)
129-
#else
127+
128+
#if canImport(Darwin)
130129
public static let signal = ProcessEvent(rawValue: 0x08000000)
131130
#endif
131+
#if os(FreeBSD) || os(OpenBSD)
132+
public static let track = ProcessEvent(rawValue: 0x00000001)
133+
#endif
132134

133-
#if os(FreeBSD)
134-
public static let all: ProcessEvent = [.exit, .fork, .exec, .track]
135-
#else
135+
#if canImport(Darwin)
136136
public static let all: ProcessEvent = [.exit, .fork, .exec, .signal]
137+
#endif
138+
#if os(FreeBSD) || os(OpenBSD)
139+
public static let all: ProcessEvent = [.exit, .fork, .exec, .track]
137140
#endif
138141
}
139142
#endif
@@ -183,7 +186,7 @@ extension DispatchSource {
183186
}
184187
#endif
185188

186-
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
189+
#if !os(Linux) && !os(Android) && !os(Windows)
187190
public class func makeProcessSource(identifier: pid_t, eventMask: ProcessEvent, queue: DispatchQueue? = nil) -> DispatchSourceProcess {
188191
let source = dispatch_source_create(_swift_dispatch_source_type_PROC(), UInt(identifier), eventMask.rawValue, queue?.__wrapped)
189192
return DispatchSource(source: source) as DispatchSourceProcess
@@ -299,7 +302,7 @@ extension DispatchSourceMemoryPressure {
299302
}
300303
#endif
301304

302-
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
305+
#if !os(Linux) && !os(Android) && !os(Windows)
303306
extension DispatchSourceProcess {
304307
public var handle: pid_t {
305308
return pid_t(CDispatch.dispatch_source_get_handle((self as! DispatchSource).__wrapped))

src/swift/Wrapper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ extension DispatchSource : DispatchSourceMachSend,
182182
}
183183
#endif
184184

185-
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
185+
#if !os(Linux) && !os(Android) && !os(Windows)
186186
extension DispatchSource : DispatchSourceProcess {
187187
}
188188
#endif
@@ -277,7 +277,7 @@ public protocol DispatchSourceMemoryPressure : DispatchSourceProtocol {
277277
}
278278
#endif
279279

280-
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
280+
#if !os(Linux) && !os(Android) && !os(Windows)
281281
public protocol DispatchSourceProcess : DispatchSourceProtocol {
282282
var handle: pid_t { get }
283283

src/swift/shims/DispatchOverlayShims.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ SWIFT_DISPATCH_SOURCE_TYPE(PROC)
8888
SWIFT_DISPATCH_SOURCE_TYPE(VNODE)
8989
#endif
9090

91-
#if defined(__FreeBSD__)
91+
#if defined(__FreeBSD__) || defined(__OpenBSD__)
9292
SWIFT_DISPATCH_SOURCE_TYPE(PROC)
9393
SWIFT_DISPATCH_SOURCE_TYPE(VNODE)
9494
#endif

0 commit comments

Comments
 (0)