diff --git a/Half.podspec b/Half.podspec index 2ef36a5..9d607a8 100644 --- a/Half.podspec +++ b/Half.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Half" - s.version = "1.4.1" + s.version = "1.4.2" s.summary = "Swift Half-Precision Floating Point" s.description = <<-DESC A lightweight framework containing a Swift implementation for a half-precision floating point type for iOS, macOS, tvOS, and watchOS. @@ -17,8 +17,9 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '12.0' s.watchos.deployment_target = '4.0' - s.source_files = 'Sources/**/*.{swift,h,c}' - s.swift_versions = ['5.0'] - s.cocoapods_version = '>= 1.7.3' + s.source_files = 'Sources/**/*.{swift,h,c}' + s.pod_target_xcconfig = { 'SWIFT_STRICT_CONCURRENCY' => 'complete' } + s.swift_versions = ['5.0'] + s.cocoapods_version = '>= 1.7.3' end diff --git a/Half.xcodeproj/project.pbxproj b/Half.xcodeproj/project.pbxproj index ec535b9..62919e8 100644 --- a/Half.xcodeproj/project.pbxproj +++ b/Half.xcodeproj/project.pbxproj @@ -1030,6 +1030,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 12.0; VERSIONING_SYSTEM = "apple-generic"; @@ -1094,6 +1095,7 @@ SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 12.0; VALIDATE_PRODUCT = YES; diff --git a/Package.swift b/Package.swift index c13aa6f..e23e57b 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.7 +// swift-tools-version:5.8 import PackageDescription let package = Package( @@ -17,9 +17,27 @@ let package = Package( targets: [ .target(name: "CHalf"), - .testTarget(name: "CHalfTests", dependencies: ["CHalf", "Half"]), + .testTarget( + name: "CHalfTests", + dependencies: ["CHalf", "Half"], + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency") + ] + ), - .target(name: "Half", dependencies: ["CHalf"]), - .testTarget(name: "HalfTests", dependencies: ["Half"]) + .target( + name: "Half", + dependencies: ["CHalf"], + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency") + ] + ), + .testTarget( + name: "HalfTests", + dependencies: ["Half"], + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency") + ] + ) ] ) diff --git a/Sources/CHalf/include/half.h b/Sources/CHalf/include/half.h index 1bfcb01..73930f2 100644 --- a/Sources/CHalf/include/half.h +++ b/Sources/CHalf/include/half.h @@ -28,10 +28,19 @@ #define HALF_FUNC HALF_CONST #define HALF_OFUNC HALF_FUNC __attribute__((__overloadable__)) +// Copied from since that header cannot be imported +#if !defined(NS_SWIFT_SENDABLE) +# if defined(__SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS) && __SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS +# define NS_SWIFT_SENDABLE __attribute__((swift_attr("@Sendable"))) +# else +# define NS_SWIFT_SENDABLE +# endif +#endif // #if !defined(NS_SWIFT_SENDABLE) + typedef union { uint16_t _bits; __fp16 _fp; -} __attribute__((packed)) half_t; +} __attribute__((packed)) NS_SWIFT_SENDABLE half_t; EXTERN_C HALF_FUNC half_t _half_zero(void); EXTERN_C HALF_FUNC half_t _half_epsilon(void); diff --git a/Sources/Half/Half.swift b/Sources/Half/Half.swift index 948ce82..9c7829a 100644 --- a/Sources/Half/Half.swift +++ b/Sources/Half/Half.swift @@ -13,12 +13,10 @@ import CHalf import CoreGraphics.CGBase #endif // #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) -#if swift(>=5.0) // MARK: - Half Definition -#if swift(>=5.1) /// A half-precision, floating-point value type. -@frozen public struct Half { +@frozen public struct Half: Sendable { // MARK: Public Properties @@ -36,27 +34,6 @@ import CoreGraphics.CGBase self._value = _value } } -#else -/// A half-precision, floating-point value type. -public struct Half { - - // MARK: Public Properties - - public var _value: half_t - - // MARK: Initialization - - @_transparent - public init() { - self._value = _half_zero() - } - - @_transparent - public init(_ _value: half_t) { - self._value = _value - } -} -#endif // MARK: - Half Extension @@ -1984,4 +1961,3 @@ extension Half: CustomPlaygroundDisplayConvertible { return Float(self) } } -#endif // #if swift(>=5.0)