Skip to content

Commit 18cceda

Browse files
authored
Support OpenBSD. (#113)
Add the usual `os` conditionals and exclude errno constants that aren't present on this platform. Maybe availability annotations are a better way to deal with this, but that is likely something that requires more careful consideration.
1 parent 252c0f0 commit 18cceda

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

Sources/System/Errno.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
12741274
@available(*, unavailable, renamed: "badMessage")
12751275
public static var EBADMSG: Errno { badMessage }
12761276

1277+
#if !os(OpenBSD)
12771278
/// Reserved.
12781279
///
12791280
/// This error is reserved for future use.
@@ -1333,6 +1334,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
13331334
@_alwaysEmitIntoClient
13341335
@available(*, unavailable, renamed: "notStream")
13351336
public static var ENOSTR: Errno { notStream }
1337+
#endif
13361338

13371339
/// Protocol error.
13381340
///
@@ -1348,6 +1350,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
13481350
@available(*, unavailable, renamed: "protocolError")
13491351
public static var EPROTO: Errno { protocolError }
13501352

1353+
#if !os(OpenBSD)
13511354
/// Reserved.
13521355
///
13531356
/// This error is reserved for future use.
@@ -1359,6 +1362,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
13591362
@_alwaysEmitIntoClient
13601363
@available(*, unavailable, renamed: "timeout")
13611364
public static var ETIME: Errno { timeout }
1365+
#endif
13621366
#endif
13631367

13641368
/// Operation not supported on socket.

Sources/System/Internals/CInterop.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public typealias CModeT = CInterop.Mode
1616

1717
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
1818
import Darwin
19-
#elseif os(Linux) || os(FreeBSD) || os(Android)
19+
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android)
2020
@_implementationOnly import CSystem
2121
import Glibc
2222
#elseif os(Windows)

Sources/System/Internals/Constants.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
1515
import Darwin
16-
#elseif os(Linux) || os(FreeBSD) || os(Android)
16+
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android)
1717
import Glibc
1818
#elseif os(Windows)
1919
import CSystem
@@ -392,6 +392,7 @@ internal var _ENOATTR: CInt { ENOATTR }
392392
@_alwaysEmitIntoClient
393393
internal var _EBADMSG: CInt { EBADMSG }
394394

395+
#if !os(OpenBSD)
395396
@_alwaysEmitIntoClient
396397
internal var _EMULTIHOP: CInt { EMULTIHOP }
397398

@@ -406,13 +407,16 @@ internal var _ENOSR: CInt { ENOSR }
406407

407408
@_alwaysEmitIntoClient
408409
internal var _ENOSTR: CInt { ENOSTR }
410+
#endif
409411

410412
@_alwaysEmitIntoClient
411413
internal var _EPROTO: CInt { EPROTO }
412414

415+
#if !os(OpenBSD)
413416
@_alwaysEmitIntoClient
414417
internal var _ETIME: CInt { ETIME }
415418
#endif
419+
#endif
416420

417421
@_alwaysEmitIntoClient
418422
internal var _EOPNOTSUPP: CInt { EOPNOTSUPP }

Sources/System/Internals/Exports.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
1616
import Darwin
17-
#elseif os(Linux) || os(FreeBSD) || os(Android)
17+
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android)
1818
@_implementationOnly import CSystem
1919
import Glibc
2020
#elseif os(Windows)

Sources/System/Internals/Syscalls.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
1111
import Darwin
12-
#elseif os(Linux) || os(FreeBSD) || os(Android)
12+
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android)
1313
import Glibc
1414
#elseif os(Windows)
1515
import ucrt

0 commit comments

Comments
 (0)