diff --git a/Package.swift b/Package.swift index 249551a3..5c4679ed 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.4 //===--- Package.swift ----------------------------------------*- swift -*-===// // // This source file is part of the Swift Numerics open source project @@ -82,13 +82,13 @@ let package = Package( ), // MARK: - Test executables - .target( + .executableTarget( name: "ComplexLog", dependencies: ["Numerics", "_TestSupport"], path: "Tests/Executable/ComplexLog" ), - .target( + .executableTarget( name: "ComplexLog1p", dependencies: ["Numerics", "_TestSupport"], path: "Tests/Executable/ComplexLog1p" diff --git a/Sources/ComplexModule/Complex+Differentiable.swift b/Sources/ComplexModule/Complex+Differentiable.swift index c38d4503..eea3816d 100644 --- a/Sources/ComplexModule/Complex+Differentiable.swift +++ b/Sources/ComplexModule/Complex+Differentiable.swift @@ -9,7 +9,9 @@ // //===----------------------------------------------------------------------===// -#if swift(>=5.3) && canImport(_Differentiation) +// STC April 2022: experimentally remove differentiable conformance to work +// around CI config failure. +#if canImport(_Differentiation) && !os(macOS) import _Differentiation extension Complex: Differentiable diff --git a/Sources/RealModule/Float16+Real.swift b/Sources/RealModule/Float16+Real.swift index c83f4947..6a991026 100644 --- a/Sources/RealModule/Float16+Real.swift +++ b/Sources/RealModule/Float16+Real.swift @@ -11,9 +11,8 @@ import _NumericsShims -// When building with a Swift 5.4 or later toolchain, Float16 is available on -// non-x86 macOS from 11.0 onward. -#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) +// Float16 is only available on macOS when targeting arm64. +#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) extension Float16: Real { @@ -175,169 +174,4 @@ extension Float16: Real { #endif } -// When building with older Swift toolchains for macOS, Float16 is not -// available. We will drop support for these older toolchains at some -// future point and remove this duplication. -#elseif swift(>=5.3) && !(os(macOS) || targetEnvironment(macCatalyst)) - -@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *) -extension Float16: Real { - @_transparent - public static func cos(_ x: Float16) -> Float16 { - Float16(.cos(Float(x))) - } - - @_transparent - public static func sin(_ x: Float16) -> Float16 { - Float16(.sin(Float(x))) - } - - @_transparent - public static func tan(_ x: Float16) -> Float16 { - Float16(.tan(Float(x))) - } - - @_transparent - public static func acos(_ x: Float16) -> Float16 { - Float16(.acos(Float(x))) - } - - @_transparent - public static func asin(_ x: Float16) -> Float16 { - Float16(.asin(Float(x))) - } - - @_transparent - public static func atan(_ x: Float16) -> Float16 { - Float16(.atan(Float(x))) - } - - @_transparent - public static func cosh(_ x: Float16) -> Float16 { - Float16(.cosh(Float(x))) - } - - @_transparent - public static func sinh(_ x: Float16) -> Float16 { - Float16(.sinh(Float(x))) - } - - @_transparent - public static func tanh(_ x: Float16) -> Float16 { - Float16(.tanh(Float(x))) - } - - @_transparent - public static func acosh(_ x: Float16) -> Float16 { - Float16(.acosh(Float(x))) - } - - @_transparent - public static func asinh(_ x: Float16) -> Float16 { - Float16(.asinh(Float(x))) - } - - @_transparent - public static func atanh(_ x: Float16) -> Float16 { - Float16(.atanh(Float(x))) - } - - @_transparent - public static func exp(_ x: Float16) -> Float16 { - Float16(.exp(Float(x))) - } - - @_transparent - public static func expMinusOne(_ x: Float16) -> Float16 { - Float16(.expMinusOne(Float(x))) - } - - @_transparent - public static func log(_ x: Float16) -> Float16 { - Float16(.log(Float(x))) - } - - @_transparent - public static func log(onePlus x: Float16) -> Float16 { - Float16(.log(onePlus: Float(x))) - } - - @_transparent - public static func erf(_ x: Float16) -> Float16 { - Float16(.erf(Float(x))) - } - - @_transparent - public static func erfc(_ x: Float16) -> Float16 { - Float16(.erfc(Float(x))) - } - - @_transparent - public static func exp2(_ x: Float16) -> Float16 { - Float16(.exp2(Float(x))) - } - - @_transparent - public static func exp10(_ x: Float16) -> Float16 { - Float16(.exp10(Float(x))) - } - - @_transparent - public static func hypot(_ x: Float16, _ y: Float16) -> Float16 { - if x.isInfinite || y.isInfinite { return .infinity } - let xf = Float(x) - let yf = Float(y) - return Float16(.sqrt(xf*xf + yf*yf)) - } - - @_transparent - public static func gamma(_ x: Float16) -> Float16 { - Float16(.gamma(Float(x))) - } - - @_transparent - public static func log2(_ x: Float16) -> Float16 { - Float16(.log2(Float(x))) - } - - @_transparent - public static func log10(_ x: Float16) -> Float16 { - Float16(.log10(Float(x))) - } - - @_transparent - public static func pow(_ x: Float16, _ y: Float16) -> Float16 { - Float16(.pow(Float(x), Float(y))) - } - - @_transparent - public static func pow(_ x: Float16, _ n: Int) -> Float16 { - // Float16 is simpler than Float or Double, because the range of - // "interesting" exponents is pretty small; anything outside of - // -22707 ... 34061 simply overflows or underflows for every - // x that isn't zero or one. This whole range is representable - // as Float, so we can just use powf as long as we're a little - // bit (get it?) careful to preserve parity. - let clamped = min(max(n, -0x10000), 0x10000) | (n & 1) - return Float16(libm_powf(Float(x), Float(clamped))) - } - - @_transparent - public static func root(_ x: Float16, _ n: Int) -> Float16 { - Float16(.root(Float(x), n)) - } - - @_transparent - public static func atan2(y: Float16, x: Float16) -> Float16 { - Float16(.atan2(y: Float(y), x: Float(x))) - } - - #if !os(Windows) - @_transparent - public static func logGamma(_ x: Float16) -> Float16 { - Float16(.logGamma(Float(x))) - } - #endif -} - #endif diff --git a/Sources/_TestSupport/RealTestSupport.swift b/Sources/_TestSupport/RealTestSupport.swift index ccabeaeb..ad90efec 100644 --- a/Sources/_TestSupport/RealTestSupport.swift +++ b/Sources/_TestSupport/RealTestSupport.swift @@ -15,7 +15,7 @@ public protocol FixedWidthFloatingPoint: BinaryFloatingPoint where Exponent: FixedWidthInteger, RawSignificand: FixedWidthInteger { } -#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) +#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) @available(macOS 11.0, iOS 14.0, watchOS 14.0, tvOS 7.0, *) extension Float16: FixedWidthFloatingPoint { } #endif diff --git a/Tests/ComplexTests/DifferentiableTests.swift b/Tests/ComplexTests/DifferentiableTests.swift index 36373098..31632bb9 100644 --- a/Tests/ComplexTests/DifferentiableTests.swift +++ b/Tests/ComplexTests/DifferentiableTests.swift @@ -9,7 +9,9 @@ // //===----------------------------------------------------------------------===// -#if swift(>=5.3) && canImport(_Differentiation) +// STC April 2022: experimentally remove differentiable conformance to work +// around CI config failure. +#if canImport(_Differentiation) && !os(macOS) import XCTest import ComplexModule diff --git a/Tests/RealTests/ElementaryFunctionChecks.swift b/Tests/RealTests/ElementaryFunctionChecks.swift index 7dfd7caf..4a5ffa4f 100644 --- a/Tests/RealTests/ElementaryFunctionChecks.swift +++ b/Tests/RealTests/ElementaryFunctionChecks.swift @@ -130,7 +130,7 @@ internal extension Real where Self: BinaryFloatingPoint { final class ElementaryFunctionChecks: XCTestCase { - #if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) + #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) func testFloat16() { if #available(macOS 11.0, iOS 14.0, watchOS 14.0, tvOS 7.0, *) { Float16.elementaryFunctionChecks() diff --git a/Tests/RealTests/IntegerExponentTests.swift b/Tests/RealTests/IntegerExponentTests.swift index 2d4a3a7d..8cc32d98 100644 --- a/Tests/RealTests/IntegerExponentTests.swift +++ b/Tests/RealTests/IntegerExponentTests.swift @@ -77,7 +77,7 @@ internal extension Real where Self: FixedWidthFloatingPoint { } } -#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) +#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) @available(macOS 11.0, iOS 14.0, watchOS 14.0, tvOS 7.0, *) extension Float16 { static func testIntegerExponent() { @@ -174,7 +174,7 @@ extension Double { final class IntegerExponentTests: XCTestCase { - #if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) + #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) func testFloat16() { if #available(macOS 11.0, iOS 14.0, watchOS 14.0, tvOS 7.0, *) { Float16.testIntegerExponent() diff --git a/Tests/WindowsMain.swift b/Tests/WindowsMain.swift index 520722af..259a0454 100644 --- a/Tests/WindowsMain.swift +++ b/Tests/WindowsMain.swift @@ -35,7 +35,7 @@ extension RealTests.ApproximateEqualityTests { ]) } -#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) +#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) extension ElementaryFunctionChecks { static var all = testCase([ ("testFloat16", ElementaryFunctionChecks.testFloat16), @@ -161,7 +161,7 @@ var testCases = [ IntegerUtilitiesTests.DoubleWidthTests.all, ] -#if swift(>=5.3) && canImport(_Differentiation) +#if canImport(_Differentiation) extension DifferentiableTests { static var all = testCase([ ("testComponentGetter", DifferentiableTests.testComponentGetter),