Skip to content

Commit 5bbf0e2

Browse files
Merge pull request #223 from stephentyrone/require-swift-5.4
Move baseline supported tools version to 5.4
2 parents 4ce74b4 + 27f8192 commit 5bbf0e2

File tree

8 files changed

+17
-179
lines changed

8 files changed

+17
-179
lines changed

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.4
22
//===--- Package.swift ----------------------------------------*- swift -*-===//
33
//
44
// This source file is part of the Swift Numerics open source project
@@ -82,13 +82,13 @@ let package = Package(
8282
),
8383

8484
// MARK: - Test executables
85-
.target(
85+
.executableTarget(
8686
name: "ComplexLog",
8787
dependencies: ["Numerics", "_TestSupport"],
8888
path: "Tests/Executable/ComplexLog"
8989
),
9090

91-
.target(
91+
.executableTarget(
9292
name: "ComplexLog1p",
9393
dependencies: ["Numerics", "_TestSupport"],
9494
path: "Tests/Executable/ComplexLog1p"

Sources/ComplexModule/Complex+Differentiable.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
#if swift(>=5.3) && canImport(_Differentiation)
12+
// STC April 2022: experimentally remove differentiable conformance to work
13+
// around CI config failure.
14+
#if canImport(_Differentiation) && !os(macOS)
1315
import _Differentiation
1416

1517
extension Complex: Differentiable

Sources/RealModule/Float16+Real.swift

Lines changed: 2 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
import _NumericsShims
1313

14-
// When building with a Swift 5.4 or later toolchain, Float16 is available on
15-
// non-x86 macOS from 11.0 onward.
16-
#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
14+
// Float16 is only available on macOS when targeting arm64.
15+
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
1716

1817
@available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
1918
extension Float16: Real {
@@ -175,169 +174,4 @@ extension Float16: Real {
175174
#endif
176175
}
177176

178-
// When building with older Swift toolchains for macOS, Float16 is not
179-
// available. We will drop support for these older toolchains at some
180-
// future point and remove this duplication.
181-
#elseif swift(>=5.3) && !(os(macOS) || targetEnvironment(macCatalyst))
182-
183-
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *)
184-
extension Float16: Real {
185-
@_transparent
186-
public static func cos(_ x: Float16) -> Float16 {
187-
Float16(.cos(Float(x)))
188-
}
189-
190-
@_transparent
191-
public static func sin(_ x: Float16) -> Float16 {
192-
Float16(.sin(Float(x)))
193-
}
194-
195-
@_transparent
196-
public static func tan(_ x: Float16) -> Float16 {
197-
Float16(.tan(Float(x)))
198-
}
199-
200-
@_transparent
201-
public static func acos(_ x: Float16) -> Float16 {
202-
Float16(.acos(Float(x)))
203-
}
204-
205-
@_transparent
206-
public static func asin(_ x: Float16) -> Float16 {
207-
Float16(.asin(Float(x)))
208-
}
209-
210-
@_transparent
211-
public static func atan(_ x: Float16) -> Float16 {
212-
Float16(.atan(Float(x)))
213-
}
214-
215-
@_transparent
216-
public static func cosh(_ x: Float16) -> Float16 {
217-
Float16(.cosh(Float(x)))
218-
}
219-
220-
@_transparent
221-
public static func sinh(_ x: Float16) -> Float16 {
222-
Float16(.sinh(Float(x)))
223-
}
224-
225-
@_transparent
226-
public static func tanh(_ x: Float16) -> Float16 {
227-
Float16(.tanh(Float(x)))
228-
}
229-
230-
@_transparent
231-
public static func acosh(_ x: Float16) -> Float16 {
232-
Float16(.acosh(Float(x)))
233-
}
234-
235-
@_transparent
236-
public static func asinh(_ x: Float16) -> Float16 {
237-
Float16(.asinh(Float(x)))
238-
}
239-
240-
@_transparent
241-
public static func atanh(_ x: Float16) -> Float16 {
242-
Float16(.atanh(Float(x)))
243-
}
244-
245-
@_transparent
246-
public static func exp(_ x: Float16) -> Float16 {
247-
Float16(.exp(Float(x)))
248-
}
249-
250-
@_transparent
251-
public static func expMinusOne(_ x: Float16) -> Float16 {
252-
Float16(.expMinusOne(Float(x)))
253-
}
254-
255-
@_transparent
256-
public static func log(_ x: Float16) -> Float16 {
257-
Float16(.log(Float(x)))
258-
}
259-
260-
@_transparent
261-
public static func log(onePlus x: Float16) -> Float16 {
262-
Float16(.log(onePlus: Float(x)))
263-
}
264-
265-
@_transparent
266-
public static func erf(_ x: Float16) -> Float16 {
267-
Float16(.erf(Float(x)))
268-
}
269-
270-
@_transparent
271-
public static func erfc(_ x: Float16) -> Float16 {
272-
Float16(.erfc(Float(x)))
273-
}
274-
275-
@_transparent
276-
public static func exp2(_ x: Float16) -> Float16 {
277-
Float16(.exp2(Float(x)))
278-
}
279-
280-
@_transparent
281-
public static func exp10(_ x: Float16) -> Float16 {
282-
Float16(.exp10(Float(x)))
283-
}
284-
285-
@_transparent
286-
public static func hypot(_ x: Float16, _ y: Float16) -> Float16 {
287-
if x.isInfinite || y.isInfinite { return .infinity }
288-
let xf = Float(x)
289-
let yf = Float(y)
290-
return Float16(.sqrt(xf*xf + yf*yf))
291-
}
292-
293-
@_transparent
294-
public static func gamma(_ x: Float16) -> Float16 {
295-
Float16(.gamma(Float(x)))
296-
}
297-
298-
@_transparent
299-
public static func log2(_ x: Float16) -> Float16 {
300-
Float16(.log2(Float(x)))
301-
}
302-
303-
@_transparent
304-
public static func log10(_ x: Float16) -> Float16 {
305-
Float16(.log10(Float(x)))
306-
}
307-
308-
@_transparent
309-
public static func pow(_ x: Float16, _ y: Float16) -> Float16 {
310-
Float16(.pow(Float(x), Float(y)))
311-
}
312-
313-
@_transparent
314-
public static func pow(_ x: Float16, _ n: Int) -> Float16 {
315-
// Float16 is simpler than Float or Double, because the range of
316-
// "interesting" exponents is pretty small; anything outside of
317-
// -22707 ... 34061 simply overflows or underflows for every
318-
// x that isn't zero or one. This whole range is representable
319-
// as Float, so we can just use powf as long as we're a little
320-
// bit (get it?) careful to preserve parity.
321-
let clamped = min(max(n, -0x10000), 0x10000) | (n & 1)
322-
return Float16(libm_powf(Float(x), Float(clamped)))
323-
}
324-
325-
@_transparent
326-
public static func root(_ x: Float16, _ n: Int) -> Float16 {
327-
Float16(.root(Float(x), n))
328-
}
329-
330-
@_transparent
331-
public static func atan2(y: Float16, x: Float16) -> Float16 {
332-
Float16(.atan2(y: Float(y), x: Float(x)))
333-
}
334-
335-
#if !os(Windows)
336-
@_transparent
337-
public static func logGamma(_ x: Float16) -> Float16 {
338-
Float16(.logGamma(Float(x)))
339-
}
340-
#endif
341-
}
342-
343177
#endif

Sources/_TestSupport/RealTestSupport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public protocol FixedWidthFloatingPoint: BinaryFloatingPoint
1515
where Exponent: FixedWidthInteger,
1616
RawSignificand: FixedWidthInteger { }
1717

18-
#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
18+
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
1919
@available(macOS 11.0, iOS 14.0, watchOS 14.0, tvOS 7.0, *)
2020
extension Float16: FixedWidthFloatingPoint { }
2121
#endif

Tests/ComplexTests/DifferentiableTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
#if swift(>=5.3) && canImport(_Differentiation)
12+
// STC April 2022: experimentally remove differentiable conformance to work
13+
// around CI config failure.
14+
#if canImport(_Differentiation) && !os(macOS)
1315

1416
import XCTest
1517
import ComplexModule

Tests/RealTests/ElementaryFunctionChecks.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ internal extension Real where Self: BinaryFloatingPoint {
130130

131131
final class ElementaryFunctionChecks: XCTestCase {
132132

133-
#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
133+
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
134134
func testFloat16() {
135135
if #available(macOS 11.0, iOS 14.0, watchOS 14.0, tvOS 7.0, *) {
136136
Float16.elementaryFunctionChecks()

Tests/RealTests/IntegerExponentTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ internal extension Real where Self: FixedWidthFloatingPoint {
7777
}
7878
}
7979

80-
#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
80+
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
8181
@available(macOS 11.0, iOS 14.0, watchOS 14.0, tvOS 7.0, *)
8282
extension Float16 {
8383
static func testIntegerExponent() {
@@ -174,7 +174,7 @@ extension Double {
174174

175175
final class IntegerExponentTests: XCTestCase {
176176

177-
#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
177+
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
178178
func testFloat16() {
179179
if #available(macOS 11.0, iOS 14.0, watchOS 14.0, tvOS 7.0, *) {
180180
Float16.testIntegerExponent()

Tests/WindowsMain.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension RealTests.ApproximateEqualityTests {
3535
])
3636
}
3737

38-
#if swift(>=5.4) && !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
38+
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
3939
extension ElementaryFunctionChecks {
4040
static var all = testCase([
4141
("testFloat16", ElementaryFunctionChecks.testFloat16),
@@ -161,7 +161,7 @@ var testCases = [
161161
IntegerUtilitiesTests.DoubleWidthTests.all,
162162
]
163163

164-
#if swift(>=5.3) && canImport(_Differentiation)
164+
#if canImport(_Differentiation)
165165
extension DifferentiableTests {
166166
static var all = testCase([
167167
("testComponentGetter", DifferentiableTests.testComponentGetter),

0 commit comments

Comments
 (0)