From 0b753a360b3e96b51e9c87f68157cb50b3200a35 Mon Sep 17 00:00:00 2001 From: Si Beaumont Date: Wed, 8 May 2024 13:24:34 +0100 Subject: [PATCH] Support compiling against Musl libc --- .../template/scaffolding.swift | 8 ++++++-- Sources/Instrumentation/Locks.swift | 8 ++++++-- Sources/Tracing/TracingTime.swift | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/IntegrationTests/allocation-counter-tests-framework/template/scaffolding.swift b/IntegrationTests/allocation-counter-tests-framework/template/scaffolding.swift index c956428..4652c37 100644 --- a/IntegrationTests/allocation-counter-tests-framework/template/scaffolding.swift +++ b/IntegrationTests/allocation-counter-tests-framework/template/scaffolding.swift @@ -28,10 +28,14 @@ import AtomicCounter import Foundation -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if canImport(Darwin) import Darwin -#else +#elseif canImport(Glibc) import Glibc +#elseif canImport(Musl) +import Musl +#else +#error("Unsupported runtime") #endif func waitForThreadsToQuiesce(shouldReachZero: Bool) { diff --git a/Sources/Instrumentation/Locks.swift b/Sources/Instrumentation/Locks.swift index 54f1d95..637493b 100644 --- a/Sources/Instrumentation/Locks.swift +++ b/Sources/Instrumentation/Locks.swift @@ -26,10 +26,14 @@ // //===----------------------------------------------------------------------===// -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if canImport(Darwin) import Darwin -#else +#elseif canImport(Glibc) import Glibc +#elseif canImport(Musl) +import Musl +#else +#error("Unsupported runtime") #endif /// A threading lock based on `libpthread` instead of `libdispatch`. diff --git a/Sources/Tracing/TracingTime.swift b/Sources/Tracing/TracingTime.swift index 3d118e5..4fe0c48 100644 --- a/Sources/Tracing/TracingTime.swift +++ b/Sources/Tracing/TracingTime.swift @@ -12,10 +12,14 @@ // //===----------------------------------------------------------------------===// -#if os(Linux) +#if canImport(Darwin) +import Darwin +#elseif canImport(Glibc) import Glibc +#elseif canImport(Musl) +import Musl #else -import Darwin +#error("Unsupported runtime") #endif @_exported import Instrumentation