Skip to content

Commit 083176e

Browse files
committed
OpenBSD support.
There is potential for simplifying some of these conditional chains. For now, I have avoided doing this since this should be picked onto the release branch and simply extending the chains limits the risk scope slightly.
1 parent b2975d8 commit 083176e

File tree

15 files changed

+28
-21
lines changed

15 files changed

+28
-21
lines changed

Sources/SwiftDocC/Benchmark/Benchmark.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class Benchmark: Encodable {
4848
public let platform = "Android"
4949
#elseif os(FreeBSD)
5050
public let platform = "FreeBSD"
51+
#elseif os(OpenBSD)
52+
public let platform = "OpenBSD"
5153
#else
5254
public let platform = "unsupported"
5355
#endif

Sources/SwiftDocC/Benchmark/Metrics/PeakMemory.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension Benchmark {
6767
) else { return nil }
6868
return Int64(pmcStats.PeakWorkingSetSize)
6969
}
70-
#elseif os(FreeBSD)
70+
#elseif os(FreeBSD) || os(OpenBSD)
7171
private static func peakMemory() -> Int64? {
7272
var usage = rusage()
7373
if (getrusage(RUSAGE_SELF, &usage) == -1) {

Sources/SwiftDocC/Infrastructure/External Data/OutOfProcessReferenceResolver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ private class LongRunningService: ExternalLinkResolving {
517517
/// This private class is only used by the ``OutOfProcessReferenceResolver`` and shouldn't be used for general communication with other processes.
518518
private class LongRunningProcess: ExternalLinkResolving {
519519

520-
#if os(macOS) || os(Linux) || os(Android) || os(FreeBSD)
520+
#if os(macOS) || os(Linux) || os(Android) || os(FreeBSD) || os(OpenBSD)
521521
private let process: Process
522522

523523
init(location: URL, errorOutputHandler: @escaping (String) -> Void) throws {

Sources/SwiftDocC/Model/Rendering/RenderContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public struct RenderContext {
6161
)
6262
}
6363

64-
#if os(macOS) || os(iOS) || os(Android) || os(Windows) || os(FreeBSD)
64+
#if os(macOS) || os(iOS) || os(Android) || os(Windows) || os(FreeBSD) || os(OpenBSD)
6565
// Concurrently render content on macOS/iOS, Windows & Android
6666
let results: [(reference: ResolvedTopicReference, content: RenderReferenceStore.TopicContent)] = references.concurrentPerform { reference, results in
6767
results.append((reference, renderContentFor(reference)))

Sources/SwiftDocC/Utility/FoundationExtensions/AutoreleasepoolShim.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11-
#if os(Linux) || os(Android) || os(Windows) || os(FreeBSD)
11+
#if os(Linux) || os(Android) || os(Windows) || os(FreeBSD) || os(OpenBSD)
1212
/// A shim for non-ObjC targets that runs the given block of code.
1313
///
1414
/// The existence of this shim allows you the use of auto-release pools to optimize memory footprint on Darwin platforms while maintaining

Sources/SwiftDocC/Utility/Synchronization.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class Synchronized<Value> {
3535
#elseif os(Linux) || os(Android)
3636
/// A lock type appropriate for the current platform.
3737
var lock: UnsafeMutablePointer<pthread_mutex_t>
38-
#elseif os(FreeBSD)
38+
#elseif os(FreeBSD) || os(OpenBSD)
3939
/// A lock type appropriate for the current platform.
4040
var lock: UnsafeMutablePointer<pthread_mutex_t?>
4141
#elseif os(Windows)
@@ -56,7 +56,7 @@ public class Synchronized<Value> {
5656
lock = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1)
5757
lock.initialize(to: pthread_mutex_t())
5858
pthread_mutex_init(lock, nil)
59-
#elseif os(FreeBSD)
59+
#elseif os(FreeBSD) || os(OpenBSD)
6060
lock = UnsafeMutablePointer<pthread_mutex_t?>.allocate(capacity: 1)
6161
lock.initialize(to: nil)
6262
pthread_mutex_init(lock, nil)
@@ -84,7 +84,7 @@ public class Synchronized<Value> {
8484
#elseif os(Linux) || os(Android)
8585
pthread_mutex_lock(lock)
8686
defer { pthread_mutex_unlock(lock) }
87-
#elseif os(FreeBSD)
87+
#elseif os(FreeBSD) || os(OpenBSD)
8888
pthread_mutex_lock(lock)
8989
defer { pthread_mutex_unlock(lock) }
9090
#elseif os(Windows)
@@ -123,7 +123,7 @@ extension Lock {
123123
#elseif os(Linux) || os(Android)
124124
pthread_mutex_lock(lock)
125125
defer { pthread_mutex_unlock(lock) }
126-
#elseif os(FreeBSD)
126+
#elseif os(FreeBSD) || os(OpenBSD)
127127
pthread_mutex_lock(lock)
128128
defer { pthread_mutex_unlock(lock) }
129129
#elseif os(Windows)

Sources/SwiftDocCUtilities/Utility/DirectoryMonitor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import Foundation
1212
import SwiftDocC
1313

14-
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
14+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
1515
import Darwin
1616

1717
/// A throttle object to filter events that come too fast.

Sources/SwiftDocCUtilities/Utility/Signal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct Signal {
2727
signalAction.__sigaction_handler = unsafeBitCast(callback, to: sigaction.__Unnamed_union___sigaction_handler.self)
2828
#elseif os(Android)
2929
signalAction.sa_handler = callback
30-
#elseif os(FreeBSD)
30+
#elseif os(FreeBSD) || os(OpenBSD)
3131
signalAction.__sigaction_u.__sa_handler = callback
3232
#else
3333
signalAction.__sigaction_u = unsafeBitCast(callback, to: __sigaction_u.self)

Sources/docc/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11-
#if os(macOS) || os(Linux) || os(Android) || os(Windows) || os(FreeBSD)
11+
#if os(macOS) || os(Linux) || os(Android) || os(Windows) || os(FreeBSD) || os(OpenBSD)
1212
import SwiftDocCUtilities
1313

1414
await Task {

Tests/SwiftDocCTests/Servers/DocumentationSchemeHandlerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DocumentationSchemeHandlerTests: XCTestCase {
2424
forResource: "LegacyBundle_DoNotUseInNewTests", withExtension: "docc", subdirectory: "Test Bundles")!
2525

2626
func testDocumentationSchemeHandler() {
27-
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
27+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
2828
let topicSchemeHandler = DocumentationSchemeHandler(withTemplateURL: templateURL)
2929

3030
let request = URLRequest(url: baseURL.appendingPathComponent("/images/figure1.jpg"))
@@ -50,7 +50,7 @@ class DocumentationSchemeHandlerTests: XCTestCase {
5050
}
5151

5252
func testSetData() {
53-
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD)
53+
#if !os(Linux) && !os(Android) && !os(Windows) && !os(FreeBSD) && !os(OpenBSD)
5454
let topicSchemeHandler = DocumentationSchemeHandler(withTemplateURL: templateURL)
5555

5656
let data = "hello!".data(using: .utf8)!

0 commit comments

Comments
 (0)