Skip to content

Commit e91c348

Browse files
3405691582dana
authored and
dana
committed
Swift support and OpenBSD.
Add the right `os(OpenBSD)` directives. Ensure `DISPATCH_COCOA_COMPAT` is defined and expose the runloop innards for `CFRunLoop` to use in Foundation down the line.
1 parent f95336f commit e91c348

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

private/private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void _dispatch_prohibit_transition_to_multithreaded(bool prohibit);
177177

178178
#if TARGET_OS_MAC
179179
#define DISPATCH_COCOA_COMPAT 1
180-
#elif defined(__linux__) || defined(__FreeBSD__) || defined(_WIN32)
180+
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(_WIN32)
181181
#define DISPATCH_COCOA_COMPAT 1
182182
#else
183183
#define DISPATCH_COCOA_COMPAT 0

src/queue.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6950,7 +6950,7 @@ _dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t dq)
69506950
_dispatch_runloop_queue_wakeup(upcast(dq)._dl, 0, false);
69516951
}
69526952

6953-
#if TARGET_OS_MAC || defined(_WIN32)
6953+
#if TARGET_OS_MAC || defined(_WIN32) || defined(__OpenBSD__)
69546954
dispatch_runloop_handle_t
69556955
_dispatch_runloop_root_queue_get_port_4CF(dispatch_queue_t dq)
69566956
{

src/swift/Source.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension DispatchSource {
116116
}
117117
#endif
118118

119-
#if !os(Linux) && !os(Android) && !os(Windows)
119+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
120120
public struct ProcessEvent : OptionSet, RawRepresentable {
121121
public let rawValue: UInt
122122
public init(rawValue: UInt) { self.rawValue = rawValue }
@@ -174,7 +174,7 @@ extension DispatchSource {
174174
}
175175
#endif
176176

177-
#if !os(Linux) && !os(Android) && !os(Windows)
177+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
178178
public class func makeProcessSource(identifier: pid_t, eventMask: ProcessEvent, queue: DispatchQueue? = nil) -> DispatchSourceProcess {
179179
let source = dispatch_source_create(_swift_dispatch_source_type_PROC(), UInt(identifier), eventMask.rawValue, queue?.__wrapped)
180180
return DispatchSource(source: source) as DispatchSourceProcess
@@ -224,7 +224,7 @@ extension DispatchSource {
224224
return DispatchSource(source: source) as DispatchSourceUserDataReplace
225225
}
226226

227-
#if !os(Linux) && !os(Android) && !os(Windows)
227+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
228228
public class func makeFileSystemObjectSource(fileDescriptor: Int32, eventMask: FileSystemEvent, queue: DispatchQueue? = nil) -> DispatchSourceFileSystemObject {
229229
let source = dispatch_source_create(_swift_dispatch_source_type_VNODE(), UInt(fileDescriptor), eventMask.rawValue, queue?.__wrapped)
230230
return DispatchSource(source: source) as DispatchSourceFileSystemObject
@@ -290,7 +290,7 @@ extension DispatchSourceMemoryPressure {
290290
}
291291
#endif
292292

293-
#if !os(Linux) && !os(Android) && !os(Windows)
293+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
294294
extension DispatchSourceProcess {
295295
public var handle: pid_t {
296296
return pid_t(dispatch_source_get_handle(self as! DispatchSource))
@@ -646,7 +646,7 @@ extension DispatchSourceTimer {
646646
}
647647
}
648648

649-
#if !os(Linux) && !os(Android) && !os(Windows)
649+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
650650
extension DispatchSourceFileSystemObject {
651651
public var handle: Int32 {
652652
return Int32(dispatch_source_get_handle((self as! DispatchSource).__wrapped))

src/swift/Wrapper.swift

+3-3
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)
185+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
186186
extension DispatchSource : DispatchSourceProcess,
187187
DispatchSourceFileSystemObject {
188188
}
@@ -273,7 +273,7 @@ public protocol DispatchSourceMemoryPressure : DispatchSourceProtocol {
273273
}
274274
#endif
275275

276-
#if !os(Linux) && !os(Android) && !os(Windows)
276+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
277277
public protocol DispatchSourceProcess : DispatchSourceProtocol {
278278
var handle: pid_t { get }
279279

@@ -303,7 +303,7 @@ public protocol DispatchSourceTimer : DispatchSourceProtocol {
303303
func scheduleRepeating(wallDeadline: DispatchWallTime, interval: Double, leeway: DispatchTimeInterval)
304304
}
305305

306-
#if !os(Linux) && !os(Android) && !os(Windows)
306+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
307307
public protocol DispatchSourceFileSystemObject : DispatchSourceProtocol {
308308
var handle: Int32 { get }
309309

0 commit comments

Comments
 (0)