Skip to content

Commit 93c000c

Browse files
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 7926966 commit 93c000c

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
@@ -6947,7 +6947,7 @@ _dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t dq)
69476947
_dispatch_runloop_queue_wakeup(upcast(dq)._dl, 0, false);
69486948
}
69496949

6950-
#if TARGET_OS_MAC || defined(_WIN32)
6950+
#if TARGET_OS_MAC || defined(_WIN32) || defined(__OpenBSD__)
69516951
dispatch_runloop_handle_t
69526952
_dispatch_runloop_root_queue_get_port_4CF(dispatch_queue_t dq)
69536953
{

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
@@ -181,7 +181,7 @@ extension DispatchSource : DispatchSourceMachSend,
181181
}
182182
#endif
183183

184-
#if !os(Linux) && !os(Android) && !os(Windows)
184+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(OpenBSD)
185185
extension DispatchSource : DispatchSourceProcess,
186186
DispatchSourceFileSystemObject {
187187
}
@@ -272,7 +272,7 @@ public protocol DispatchSourceMemoryPressure : DispatchSourceProtocol {
272272
}
273273
#endif
274274

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

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

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

0 commit comments

Comments
 (0)