diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b5c5eb7..ddeff52 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,7 +9,7 @@ jobs: name: Test uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main with: - linux_exclude_swift_versions: '[{"swift_version": "5.8"}]' + linux_exclude_swift_versions: '[{"swift_version": "5.8"}, {"swift_version": "5.9"}]' windows_exclude_swift_versions: '[{"swift_version": "5.9"}]' soundness: diff --git a/CMakeLists.txt b/CMakeLists.txt index f0a5a1c..1073ba7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ #[[ This source file is part of the Swift Atomics Open Source Project -Copyright (c) 2021 Apple Inc. and the Swift project authors +Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -31,10 +31,7 @@ set(ATOMICS_C_FLAGS) if(CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 5.9) list(APPEND ATOMICS_SWIFT_FLAGS "-enable-experimental-feature BuiltinModule" - "-DATOMICS_NATIVE_BUILTINS" - "-Xcc" "-DATOMICS_NATIVE_BUILTINS=1") - list(APPEND ATOMICS_C_FLAGS - "-DATOMICS_NATIVE_BUILTINS=1") + ) endif() add_subdirectory(Sources) diff --git a/Package.swift b/Package.swift index 6d50358..5aace10 100644 --- a/Package.swift +++ b/Package.swift @@ -1,9 +1,9 @@ -// swift-tools-version:5.9 +// swift-tools-version:5.10 //===----------------------------------------------------------------------===// // // This source file is part of the Swift.org open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -18,10 +18,8 @@ var _swiftSettings: [SwiftSetting] = [] // Enable the use of native Swift compiler builtins instead of C atomics. _cSettings += [ - .define("ATOMICS_NATIVE_BUILTINS"), ] _swiftSettings += [ - .define("ATOMICS_NATIVE_BUILTINS"), .enableExperimentalFeature("BuiltinModule") ] @@ -48,7 +46,6 @@ let package = Package( "Conformances/IntegerConformances.swift.gyb", "Conformances/PointerConformances.swift.gyb", "Primitives/Primitives.native.swift.gyb", - "Primitives/Primitives.shims.swift.gyb", "Types/IntegerOperations.swift.gyb", ], cSettings: _cSettings, diff --git a/Package@swift-5.7.swift b/Package@swift-5.7.swift deleted file mode 100644 index e2b822e..0000000 --- a/Package@swift-5.7.swift +++ /dev/null @@ -1,87 +0,0 @@ -// swift-tools-version:5.7 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -var _cSettings: [CSetting] = [] -var _swiftSettings: [SwiftSetting] = [] - -// Note: ATOMICS_NATIVE_BUILTINS works via the BuiltinModule language feature, -// so it is not usable in language versions below 5.9. - -let package = Package( - name: "swift-atomics", - products: [ - .library( - name: "Atomics", - targets: ["Atomics"]), - ], - targets: [ - .target( - name: "_AtomicsShims", - exclude: [ - "CMakeLists.txt" - ] - ), - .target( - name: "Atomics", - dependencies: ["_AtomicsShims"], - exclude: [ - "CMakeLists.txt", - "Conformances/AtomicBool.swift.gyb", - "Conformances/IntegerConformances.swift.gyb", - "Conformances/PointerConformances.swift.gyb", - "Primitives/Primitives.native.swift.gyb", - "Primitives/Primitives.shims.swift.gyb", - "Types/IntegerOperations.swift.gyb", - ], - cSettings: _cSettings, - swiftSettings: _swiftSettings - ), - .testTarget( - name: "AtomicsTests", - dependencies: ["Atomics"], - exclude: [ - "main.swift", - "Basics/BasicTests.gyb-template", - "Basics/BasicAtomicBoolTests.swift.gyb", - "Basics/BasicAtomicDoubleWordTests.swift.gyb", - "Basics/BasicAtomicInt16Tests.swift.gyb", - "Basics/BasicAtomicInt32Tests.swift.gyb", - "Basics/BasicAtomicInt64Tests.swift.gyb", - "Basics/BasicAtomicInt8Tests.swift.gyb", - "Basics/BasicAtomicIntTests.swift.gyb", - "Basics/BasicAtomicMutablePointerTests.swift.gyb", - "Basics/BasicAtomicMutableRawPointerTests.swift.gyb", - "Basics/BasicAtomicOptionalMutablePointerTests.swift.gyb", - "Basics/BasicAtomicOptionalMutableRawPointerTests.swift.gyb", - "Basics/BasicAtomicOptionalPointerTests.swift.gyb", - "Basics/BasicAtomicOptionalRawPointerTests.swift.gyb", - "Basics/BasicAtomicOptionalRawRepresentableTests.swift.gyb", - "Basics/BasicAtomicOptionalReferenceTests.swift.gyb", - "Basics/BasicAtomicOptionalUnmanagedTests.swift.gyb", - "Basics/BasicAtomicPointerTests.swift.gyb", - "Basics/BasicAtomicRawPointerTests.swift.gyb", - "Basics/BasicAtomicRawRepresentableTests.swift.gyb", - "Basics/BasicAtomicReferenceTests.swift.gyb", - "Basics/BasicAtomicUInt16Tests.swift.gyb", - "Basics/BasicAtomicUInt32Tests.swift.gyb", - "Basics/BasicAtomicUInt64Tests.swift.gyb", - "Basics/BasicAtomicUInt8Tests.swift.gyb", - "Basics/BasicAtomicUIntTests.swift.gyb", - "Basics/BasicAtomicUnmanagedTests.swift.gyb", - ], - swiftSettings: _swiftSettings - ), - ] -) diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift deleted file mode 100644 index e2b822e..0000000 --- a/Package@swift-5.8.swift +++ /dev/null @@ -1,87 +0,0 @@ -// swift-tools-version:5.7 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -var _cSettings: [CSetting] = [] -var _swiftSettings: [SwiftSetting] = [] - -// Note: ATOMICS_NATIVE_BUILTINS works via the BuiltinModule language feature, -// so it is not usable in language versions below 5.9. - -let package = Package( - name: "swift-atomics", - products: [ - .library( - name: "Atomics", - targets: ["Atomics"]), - ], - targets: [ - .target( - name: "_AtomicsShims", - exclude: [ - "CMakeLists.txt" - ] - ), - .target( - name: "Atomics", - dependencies: ["_AtomicsShims"], - exclude: [ - "CMakeLists.txt", - "Conformances/AtomicBool.swift.gyb", - "Conformances/IntegerConformances.swift.gyb", - "Conformances/PointerConformances.swift.gyb", - "Primitives/Primitives.native.swift.gyb", - "Primitives/Primitives.shims.swift.gyb", - "Types/IntegerOperations.swift.gyb", - ], - cSettings: _cSettings, - swiftSettings: _swiftSettings - ), - .testTarget( - name: "AtomicsTests", - dependencies: ["Atomics"], - exclude: [ - "main.swift", - "Basics/BasicTests.gyb-template", - "Basics/BasicAtomicBoolTests.swift.gyb", - "Basics/BasicAtomicDoubleWordTests.swift.gyb", - "Basics/BasicAtomicInt16Tests.swift.gyb", - "Basics/BasicAtomicInt32Tests.swift.gyb", - "Basics/BasicAtomicInt64Tests.swift.gyb", - "Basics/BasicAtomicInt8Tests.swift.gyb", - "Basics/BasicAtomicIntTests.swift.gyb", - "Basics/BasicAtomicMutablePointerTests.swift.gyb", - "Basics/BasicAtomicMutableRawPointerTests.swift.gyb", - "Basics/BasicAtomicOptionalMutablePointerTests.swift.gyb", - "Basics/BasicAtomicOptionalMutableRawPointerTests.swift.gyb", - "Basics/BasicAtomicOptionalPointerTests.swift.gyb", - "Basics/BasicAtomicOptionalRawPointerTests.swift.gyb", - "Basics/BasicAtomicOptionalRawRepresentableTests.swift.gyb", - "Basics/BasicAtomicOptionalReferenceTests.swift.gyb", - "Basics/BasicAtomicOptionalUnmanagedTests.swift.gyb", - "Basics/BasicAtomicPointerTests.swift.gyb", - "Basics/BasicAtomicRawPointerTests.swift.gyb", - "Basics/BasicAtomicRawRepresentableTests.swift.gyb", - "Basics/BasicAtomicReferenceTests.swift.gyb", - "Basics/BasicAtomicUInt16Tests.swift.gyb", - "Basics/BasicAtomicUInt32Tests.swift.gyb", - "Basics/BasicAtomicUInt64Tests.swift.gyb", - "Basics/BasicAtomicUInt8Tests.swift.gyb", - "Basics/BasicAtomicUIntTests.swift.gyb", - "Basics/BasicAtomicUnmanagedTests.swift.gyb", - ], - swiftSettings: _swiftSettings - ), - ] -) diff --git a/Sources/Atomics/CMakeLists.txt b/Sources/Atomics/CMakeLists.txt index e7cde36..e69f2d1 100644 --- a/Sources/Atomics/CMakeLists.txt +++ b/Sources/Atomics/CMakeLists.txt @@ -1,7 +1,7 @@ #[[ This source file is part of the Swift Atomics Open Source Project -Copyright (c) 2021 - 2023 Apple Inc. and the Swift project authors +Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -17,7 +17,6 @@ add_library(Atomics "Types/autogenerated/IntegerOperations.swift" "Unmanaged extensions.swift" "Primitives/autogenerated/Primitives.native.swift" - "Primitives/autogenerated/Primitives.shims.swift" "Conformances/RawRepresentable.swift" "Conformances/OptionalRawRepresentable.swift" "Conformances/autogenerated/IntegerConformances.swift" diff --git a/Sources/Atomics/Conformances/AtomicBool.swift.gyb b/Sources/Atomics/Conformances/AtomicBool.swift.gyb index 154ca6b..bd16d41 100644 --- a/Sources/Atomics/Conformances/AtomicBool.swift.gyb +++ b/Sources/Atomics/Conformances/AtomicBool.swift.gyb @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -16,7 +16,6 @@ }% ${autogenerated_warning()} -#if ATOMICS_NATIVE_BUILTINS import Builtin extension Bool { @@ -26,9 +25,6 @@ extension Bool { self = unsafeBitCast(builtin, to: Bool.self) } } -#else -import _AtomicsShims -#endif extension Bool: AtomicValue { @frozen @@ -43,25 +39,16 @@ extension Bool: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Bool) { -#if ATOMICS_NATIVE_BUILTINS _storage = value._atomicRepresentation -#else - _storage = _sa_prepare_Int8(value._atomicRepresentation) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return _storage._decodeBool -#else - return _sa_dispose_Int8(_storage)._decodeBool -#endif } } } -#if ATOMICS_NATIVE_BUILTINS extension Bool { @_transparent @_alwaysEmitIntoClient internal var _atomicRepresentation: _AtomicInt8Storage { @@ -76,21 +63,6 @@ extension _AtomicInt8Storage { (Int8(self._value) & 1) != 0 } } -#else -extension Bool { - @_transparent @_alwaysEmitIntoClient - internal var _atomicRepresentation: Int8 { - self ? 1 : 0 - } -} - -extension Int8 { - @_transparent @_alwaysEmitIntoClient - internal var _decodeBool: Bool { - (self & 1) != 0 - } -} -#endif extension UnsafeMutablePointer where Pointee == Bool.AtomicRepresentation { diff --git a/Sources/Atomics/Conformances/IntegerConformances.swift.gyb b/Sources/Atomics/Conformances/IntegerConformances.swift.gyb index 9c251a6..828ab7a 100644 --- a/Sources/Atomics/Conformances/IntegerConformances.swift.gyb +++ b/Sources/Atomics/Conformances/IntegerConformances.swift.gyb @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -29,10 +29,6 @@ }% ${autogenerated_warning()} -#if !ATOMICS_NATIVE_BUILTINS -import _AtomicsShims -#endif - % for (swiftType, storageType, shimType) in integerTypes: extension ${swiftType}: AtomicValue { @@ -48,20 +44,12 @@ extension ${swiftType}: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_${shimType}(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_${shimType}(_storage)) -#endif } } } @@ -76,7 +64,6 @@ where Pointee == ${swiftType}.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension ${swiftType}.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -88,27 +75,6 @@ extension ${swiftType}.AtomicRepresentation { return _Storage(value._value) } } -#else -extension ${swiftType}.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: ${shimType}) -> Value { -% if swiftType == shimType: - return v -% else: - return Value(v._value) -% end - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> ${shimType} { -% if swiftType == shimType: - return value -% else: - return ${shimType}(value._value) -% end - } -} -#endif extension ${swiftType}.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") diff --git a/Sources/Atomics/Conformances/PointerConformances.swift.gyb b/Sources/Atomics/Conformances/PointerConformances.swift.gyb index 9a28231..e91e357 100644 --- a/Sources/Atomics/Conformances/PointerConformances.swift.gyb +++ b/Sources/Atomics/Conformances/PointerConformances.swift.gyb @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -23,10 +23,6 @@ }% ${autogenerated_warning()} -#if !ATOMICS_NATIVE_BUILTINS -import _AtomicsShims -#endif - % for swiftType in atomicTypes: extension ${swiftType}: AtomicValue { @frozen @@ -41,20 +37,12 @@ extension ${swiftType}: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -71,7 +59,6 @@ extension ${swiftType}.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension ${swiftType}.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -93,27 +80,6 @@ extension ${swiftType}.AtomicRepresentation { return _Storage(bits._value) } } -#else -extension ${swiftType}.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - % if swiftType == "Unmanaged": - return Unmanaged.fromOpaque(UnsafeRawPointer(bitPattern: bits)!) - % else: - return ${swiftType}(bitPattern: bits)! - % end - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - % if swiftType == "Unmanaged": - return Int(bitPattern: value.toOpaque()) - % else: - return Int(bitPattern: value) - % end - } -} -#endif extension ${swiftType}.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -213,20 +179,12 @@ extension ${swiftType}: AtomicOptionalWrappable { @inline(__always) @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @inline(__always) @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -243,7 +201,6 @@ extension ${swiftType}.AtomicOptionalRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension ${swiftType}.AtomicOptionalRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -268,30 +225,6 @@ extension ${swiftType}.AtomicOptionalRepresentation { return _Storage(bits._value) } } -#else -extension ${swiftType}.AtomicOptionalRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - % if swiftType == "Unmanaged": - guard let opaque = UnsafeRawPointer(bitPattern: bits) else { - return nil - } - return Unmanaged.fromOpaque(opaque) - % else: - return ${swiftType}(bitPattern: bits) - % end - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - % if swiftType == "Unmanaged": - return value.map { Int(bitPattern: $0.toOpaque())} ?? 0 - % else: - return value.map { Int(bitPattern: $0) } ?? 0 - % end - } -} -#endif extension ${swiftType}.AtomicOptionalRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") diff --git a/Sources/Atomics/Conformances/autogenerated/AtomicBool.swift b/Sources/Atomics/Conformances/autogenerated/AtomicBool.swift index 73b52e6..79206f8 100644 --- a/Sources/Atomics/Conformances/autogenerated/AtomicBool.swift +++ b/Sources/Atomics/Conformances/autogenerated/AtomicBool.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -18,7 +18,6 @@ // ############################################################################# -#if ATOMICS_NATIVE_BUILTINS import Builtin extension Bool { @@ -28,9 +27,6 @@ extension Bool { self = unsafeBitCast(builtin, to: Bool.self) } } -#else -import _AtomicsShims -#endif extension Bool: AtomicValue { @frozen @@ -45,25 +41,16 @@ extension Bool: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Bool) { -#if ATOMICS_NATIVE_BUILTINS _storage = value._atomicRepresentation -#else - _storage = _sa_prepare_Int8(value._atomicRepresentation) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return _storage._decodeBool -#else - return _sa_dispose_Int8(_storage)._decodeBool -#endif } } } -#if ATOMICS_NATIVE_BUILTINS extension Bool { @_transparent @_alwaysEmitIntoClient internal var _atomicRepresentation: _AtomicInt8Storage { @@ -78,21 +65,6 @@ extension _AtomicInt8Storage { (Int8(self._value) & 1) != 0 } } -#else -extension Bool { - @_transparent @_alwaysEmitIntoClient - internal var _atomicRepresentation: Int8 { - self ? 1 : 0 - } -} - -extension Int8 { - @_transparent @_alwaysEmitIntoClient - internal var _decodeBool: Bool { - (self & 1) != 0 - } -} -#endif extension UnsafeMutablePointer where Pointee == Bool.AtomicRepresentation { diff --git a/Sources/Atomics/Conformances/autogenerated/IntegerConformances.swift b/Sources/Atomics/Conformances/autogenerated/IntegerConformances.swift index 15a485f..c7a373d 100644 --- a/Sources/Atomics/Conformances/autogenerated/IntegerConformances.swift +++ b/Sources/Atomics/Conformances/autogenerated/IntegerConformances.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -17,10 +17,6 @@ // ############################################################################# -#if !ATOMICS_NATIVE_BUILTINS -import _AtomicsShims -#endif - extension Int8: AtomicValue { @frozen @@ -35,20 +31,12 @@ extension Int8: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int8(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int8(_storage)) -#endif } } } @@ -63,7 +51,6 @@ where Pointee == Int8.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension Int8.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -75,19 +62,6 @@ extension Int8.AtomicRepresentation { return _Storage(value._value) } } -#else -extension Int8.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int8) -> Value { - return v - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int8 { - return value - } -} -#endif extension Int8.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -260,20 +234,12 @@ extension Int16: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int16(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int16(_storage)) -#endif } } } @@ -288,7 +254,6 @@ where Pointee == Int16.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension Int16.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -300,19 +265,6 @@ extension Int16.AtomicRepresentation { return _Storage(value._value) } } -#else -extension Int16.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int16) -> Value { - return v - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int16 { - return value - } -} -#endif extension Int16.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -485,20 +437,12 @@ extension Int32: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int32(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int32(_storage)) -#endif } } } @@ -513,7 +457,6 @@ where Pointee == Int32.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension Int32.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -525,19 +468,6 @@ extension Int32.AtomicRepresentation { return _Storage(value._value) } } -#else -extension Int32.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int32) -> Value { - return v - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int32 { - return value - } -} -#endif extension Int32.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -710,20 +640,12 @@ extension Int64: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int64(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int64(_storage)) -#endif } } } @@ -738,7 +660,6 @@ where Pointee == Int64.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension Int64.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -750,19 +671,6 @@ extension Int64.AtomicRepresentation { return _Storage(value._value) } } -#else -extension Int64.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int64) -> Value { - return v - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int64 { - return value - } -} -#endif extension Int64.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -935,20 +843,12 @@ extension UInt8: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int8(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int8(_storage)) -#endif } } } @@ -963,7 +863,6 @@ where Pointee == UInt8.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UInt8.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -975,19 +874,6 @@ extension UInt8.AtomicRepresentation { return _Storage(value._value) } } -#else -extension UInt8.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int8) -> Value { - return Value(v._value) - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int8 { - return Int8(value._value) - } -} -#endif extension UInt8.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -1160,20 +1046,12 @@ extension UInt16: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int16(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int16(_storage)) -#endif } } } @@ -1188,7 +1066,6 @@ where Pointee == UInt16.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UInt16.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -1200,19 +1077,6 @@ extension UInt16.AtomicRepresentation { return _Storage(value._value) } } -#else -extension UInt16.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int16) -> Value { - return Value(v._value) - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int16 { - return Int16(value._value) - } -} -#endif extension UInt16.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -1385,20 +1249,12 @@ extension UInt32: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int32(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int32(_storage)) -#endif } } } @@ -1413,7 +1269,6 @@ where Pointee == UInt32.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UInt32.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -1425,19 +1280,6 @@ extension UInt32.AtomicRepresentation { return _Storage(value._value) } } -#else -extension UInt32.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int32) -> Value { - return Value(v._value) - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int32 { - return Int32(value._value) - } -} -#endif extension UInt32.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -1610,20 +1452,12 @@ extension UInt64: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int64(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int64(_storage)) -#endif } } } @@ -1638,7 +1472,6 @@ where Pointee == UInt64.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UInt64.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -1650,19 +1483,6 @@ extension UInt64.AtomicRepresentation { return _Storage(value._value) } } -#else -extension UInt64.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int64) -> Value { - return Value(v._value) - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int64 { - return Int64(value._value) - } -} -#endif extension UInt64.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -1835,20 +1655,12 @@ extension Int: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -1863,7 +1675,6 @@ where Pointee == Int.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension Int.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -1875,19 +1686,6 @@ extension Int.AtomicRepresentation { return _Storage(value._value) } } -#else -extension Int.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int) -> Value { - return v - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int { - return value - } -} -#endif extension Int.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -2060,20 +1858,12 @@ extension UInt: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -2088,7 +1878,6 @@ where Pointee == UInt.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UInt.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -2100,19 +1889,6 @@ extension UInt.AtomicRepresentation { return _Storage(value._value) } } -#else -extension UInt.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: Int) -> Value { - return Value(v._value) - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> Int { - return Int(value._value) - } -} -#endif extension UInt.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -2285,20 +2061,12 @@ extension DoubleWord: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_DoubleWord(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_DoubleWord(_storage)) -#endif } } } @@ -2313,7 +2081,6 @@ where Pointee == DoubleWord.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension DoubleWord.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient static func _decode(_ storage: _Storage) -> Value { @@ -2325,19 +2092,6 @@ extension DoubleWord.AtomicRepresentation { return _Storage(value._value) } } -#else -extension DoubleWord.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - static func _decode(_ v: DoubleWord) -> Value { - return v - } - - @_transparent @_alwaysEmitIntoClient - static func _encode(_ value: Value) -> DoubleWord { - return value - } -} -#endif extension DoubleWord.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") diff --git a/Sources/Atomics/Conformances/autogenerated/PointerConformances.swift b/Sources/Atomics/Conformances/autogenerated/PointerConformances.swift index 415fa27..03800f1 100644 --- a/Sources/Atomics/Conformances/autogenerated/PointerConformances.swift +++ b/Sources/Atomics/Conformances/autogenerated/PointerConformances.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -18,10 +18,6 @@ // ############################################################################# -#if !ATOMICS_NATIVE_BUILTINS -import _AtomicsShims -#endif - extension UnsafeRawPointer: AtomicValue { @frozen public struct AtomicRepresentation { @@ -35,20 +31,12 @@ extension UnsafeRawPointer: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -65,7 +53,6 @@ extension UnsafeRawPointer.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UnsafeRawPointer.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -79,19 +66,6 @@ extension UnsafeRawPointer.AtomicRepresentation { return _Storage(bits._value) } } -#else -extension UnsafeRawPointer.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return UnsafeRawPointer(bitPattern: bits)! - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return Int(bitPattern: value) - } -} -#endif extension UnsafeRawPointer.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -187,20 +161,12 @@ extension UnsafeMutableRawPointer: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -217,7 +183,6 @@ extension UnsafeMutableRawPointer.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UnsafeMutableRawPointer.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -231,19 +196,6 @@ extension UnsafeMutableRawPointer.AtomicRepresentation { return _Storage(bits._value) } } -#else -extension UnsafeMutableRawPointer.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return UnsafeMutableRawPointer(bitPattern: bits)! - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return Int(bitPattern: value) - } -} -#endif extension UnsafeMutableRawPointer.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -339,20 +291,12 @@ extension UnsafePointer: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -369,7 +313,6 @@ extension UnsafePointer.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UnsafePointer.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -383,19 +326,6 @@ extension UnsafePointer.AtomicRepresentation { return _Storage(bits._value) } } -#else -extension UnsafePointer.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return UnsafePointer(bitPattern: bits)! - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return Int(bitPattern: value) - } -} -#endif extension UnsafePointer.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -491,20 +421,12 @@ extension UnsafeMutablePointer: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -521,7 +443,6 @@ extension UnsafeMutablePointer.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UnsafeMutablePointer.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -535,19 +456,6 @@ extension UnsafeMutablePointer.AtomicRepresentation { return _Storage(bits._value) } } -#else -extension UnsafeMutablePointer.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return UnsafeMutablePointer(bitPattern: bits)! - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return Int(bitPattern: value) - } -} -#endif extension UnsafeMutablePointer.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -643,20 +551,12 @@ extension Unmanaged: AtomicValue { @_transparent @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @_transparent @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS return Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -673,7 +573,6 @@ extension Unmanaged.AtomicRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension Unmanaged.AtomicRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -687,19 +586,6 @@ extension Unmanaged.AtomicRepresentation { return _Storage(bits._value) } } -#else -extension Unmanaged.AtomicRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return Unmanaged.fromOpaque(UnsafeRawPointer(bitPattern: bits)!) - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return Int(bitPattern: value.toOpaque()) - } -} -#endif extension Unmanaged.AtomicRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -797,20 +683,12 @@ extension UnsafeRawPointer: AtomicOptionalWrappable { @inline(__always) @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @inline(__always) @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -827,7 +705,6 @@ extension UnsafeRawPointer.AtomicOptionalRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UnsafeRawPointer.AtomicOptionalRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -841,19 +718,6 @@ extension UnsafeRawPointer.AtomicOptionalRepresentation { return _Storage(bits._value) } } -#else -extension UnsafeRawPointer.AtomicOptionalRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return UnsafeRawPointer(bitPattern: bits) - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return value.map { Int(bitPattern: $0) } ?? 0 - } -} -#endif extension UnsafeRawPointer.AtomicOptionalRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -947,20 +811,12 @@ extension UnsafeMutableRawPointer: AtomicOptionalWrappable { @inline(__always) @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @inline(__always) @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -977,7 +833,6 @@ extension UnsafeMutableRawPointer.AtomicOptionalRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UnsafeMutableRawPointer.AtomicOptionalRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -991,19 +846,6 @@ extension UnsafeMutableRawPointer.AtomicOptionalRepresentation { return _Storage(bits._value) } } -#else -extension UnsafeMutableRawPointer.AtomicOptionalRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return UnsafeMutableRawPointer(bitPattern: bits) - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return value.map { Int(bitPattern: $0) } ?? 0 - } -} -#endif extension UnsafeMutableRawPointer.AtomicOptionalRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -1097,20 +939,12 @@ extension UnsafePointer: AtomicOptionalWrappable { @inline(__always) @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @inline(__always) @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -1127,7 +961,6 @@ extension UnsafePointer.AtomicOptionalRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UnsafePointer.AtomicOptionalRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -1141,19 +974,6 @@ extension UnsafePointer.AtomicOptionalRepresentation { return _Storage(bits._value) } } -#else -extension UnsafePointer.AtomicOptionalRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return UnsafePointer(bitPattern: bits) - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return value.map { Int(bitPattern: $0) } ?? 0 - } -} -#endif extension UnsafePointer.AtomicOptionalRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -1247,20 +1067,12 @@ extension UnsafeMutablePointer: AtomicOptionalWrappable { @inline(__always) @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @inline(__always) @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -1277,7 +1089,6 @@ extension UnsafeMutablePointer.AtomicOptionalRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension UnsafeMutablePointer.AtomicOptionalRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -1291,19 +1102,6 @@ extension UnsafeMutablePointer.AtomicOptionalRepresentation { return _Storage(bits._value) } } -#else -extension UnsafeMutablePointer.AtomicOptionalRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - return UnsafeMutablePointer(bitPattern: bits) - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return value.map { Int(bitPattern: $0) } ?? 0 - } -} -#endif extension UnsafeMutablePointer.AtomicOptionalRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") @@ -1397,20 +1195,12 @@ extension Unmanaged: AtomicOptionalWrappable { @inline(__always) @_alwaysEmitIntoClient public init(_ value: Value) { -#if ATOMICS_NATIVE_BUILTINS _storage = Self._encode(value) -#else - _storage = _sa_prepare_Int(Self._encode(value)) -#endif } @inline(__always) @_alwaysEmitIntoClient public func dispose() -> Value { -#if ATOMICS_NATIVE_BUILTINS Self._decode(_storage) -#else - return Self._decode(_sa_dispose_Int(_storage)) -#endif } } } @@ -1427,7 +1217,6 @@ extension Unmanaged.AtomicOptionalRepresentation { } } -#if ATOMICS_NATIVE_BUILTINS extension Unmanaged.AtomicOptionalRepresentation { @_transparent @_alwaysEmitIntoClient internal static func _decode(_ storage: _Storage) -> Value { @@ -1444,22 +1233,6 @@ extension Unmanaged.AtomicOptionalRepresentation { return _Storage(bits._value) } } -#else -extension Unmanaged.AtomicOptionalRepresentation { - @_transparent @_alwaysEmitIntoClient - internal static func _decode(_ bits: Int) -> Value { - guard let opaque = UnsafeRawPointer(bitPattern: bits) else { - return nil - } - return Unmanaged.fromOpaque(opaque) - } - - @_transparent @_alwaysEmitIntoClient - internal static func _encode(_ value: Value) -> Int { - return value.map { Int(bitPattern: $0.toOpaque())} ?? 0 - } -} -#endif extension Unmanaged.AtomicOptionalRepresentation: AtomicStorage { @_semantics("atomics.requires_constant_orderings") diff --git a/Sources/Atomics/Primitives/Primitives.native.swift.gyb b/Sources/Atomics/Primitives/Primitives.native.swift.gyb index bfa9657..f00c3f2 100644 --- a/Sources/Atomics/Primitives/Primitives.native.swift.gyb +++ b/Sources/Atomics/Primitives/Primitives.native.swift.gyb @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2023 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -15,13 +15,6 @@ }% ${autogenerated_warning()} -// FIXME: The conditionals below have been carefully constructed to -// avoid confusing Swift 5.7; they can be sanitized once we drop support -// for that version. -#if compiler(>=5.9) -#if !ATOMICS_NATIVE_BUILTINS -#error("swift-atomics requires native builtins on Swift 5.9") -#endif import Builtin @_alwaysEmitIntoClient @@ -282,9 +275,3 @@ extension UnsafeMutablePointer where Pointee == ${swiftType} { #else #error("Unexpected pointer bit width") #endif - -#else // compiler(>=5.9) -#if ATOMICS_NATIVE_BUILTINS -#error("swift-atomics requires C shims on Swift versions below 5.9") -#endif -#endif // compiler(>=5.9) diff --git a/Sources/Atomics/Primitives/Primitives.shims.swift.gyb b/Sources/Atomics/Primitives/Primitives.shims.swift.gyb deleted file mode 100644 index cdd8b7a..0000000 --- a/Sources/Atomics/Primitives/Primitives.shims.swift.gyb +++ /dev/null @@ -1,257 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -%{ - from gyb_utils import * -}% -${autogenerated_warning()} - -#if !ATOMICS_NATIVE_BUILTINS -import _AtomicsShims - -@_alwaysEmitIntoClient -@_transparent -internal func _atomicMemoryFence( - ordering: AtomicUpdateOrdering -) { - switch ordering { - case .relaxed: - break -% for (enumOrder, apiOrder, docOrder, llvmOrder, _) in updateOrderings: -% if enumOrder != "relaxed": - case .${enumOrder}: - _sa_thread_fence_${shim_name(llvmOrder)}() -% end -% end - default: - fatalError("Unsupported ordering") - } -} - -% for (storageType, valueType) in cPrimitives: -extension UnsafeMutablePointer where Pointee == ${storageType} { - /// Atomically loads a word starting at this address with the specified - /// memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicLoad(ordering: AtomicLoadOrdering) -> ${valueType} { - switch ordering { -% for (enumOrder, apiOrder, docOrder, llvmOrder) in loadOrderings: - case .${enumOrder}: - return _sa_load_${shim_name(llvmOrder)}_${valueType}(self) -% end - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicStore( - _ desired: ${valueType}, - ordering: AtomicStoreOrdering - ) { - switch ordering { -% for (enumOrder, apiOrder, docOrder, llvmOrder) in storeOrderings: - case .${enumOrder}: - _sa_store_${shim_name(llvmOrder)}_${valueType}(self, desired) -% end - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicExchange( - _ desired: ${valueType}, - ordering: AtomicUpdateOrdering - ) -> ${valueType} { - switch ordering { -% for (enumOrder, apiOrder, docOrder, llvmOrder, failOrder) in updateOrderings: - case .${enumOrder}: - return _sa_exchange_${shim_name(llvmOrder)}_${valueType}(self, desired) -% end - default: - fatalError("Unsupported ordering") - } - } - - /// Perform an atomic compare and exchange operation with the specified memory - /// ordering. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: ${valueType}, - desired: ${valueType}, - ordering: AtomicUpdateOrdering - ) -> (exchanged: Bool, original: ${valueType}) { - var expected = expected - let exchanged: Bool - switch ordering { -% for (enumOrder, apiOrder, docOrder, llvmOrder, failOrder) in updateOrderings: - case .${enumOrder}: - exchanged = _sa_cmpxchg_strong_${shim_name(llvmOrder)}_${shim_name(failOrder)}_${valueType}( - self, &expected, desired) -% end - default: - fatalError("Unsupported ordering") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: ${valueType}, - desired: ${valueType}, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: ${valueType}) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { -% for (swiftSuccess, apiSuccess, _, llvmOrder, _) in updateOrderings: -% for (swiftFailure, apiFailure, _, llvmFailure) in loadOrderings: - case (.${swiftSuccess}, .${swiftFailure}): - exchanged = _sa_cmpxchg_strong_${actualShimOrders(llvmOrder, llvmFailure)}_${valueType}( - self, &expected, desired) -% end -% end - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicWeakCompareExchange( - expected: ${valueType}, - desired: ${valueType}, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: ${valueType}) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { -% for (swiftSuccess, apiSuccess, _, llvmOrder, _) in updateOrderings: -% for (swiftFailure, apiFailure, _, llvmFailure) in loadOrderings: - case (.${swiftSuccess}, .${swiftFailure}): - exchanged = _sa_cmpxchg_weak_${actualShimOrders(llvmOrder, llvmFailure)}_${valueType}( - self, &expected, desired) -% end -% end - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - -% if valueType != "DoubleWord": -% for (swiftName, builtinName, operator, label, doc) in integerOperations: - /// Perform an atomic ${doc} operation and return the new value, - /// with the specified memory ordering. - /// - % if "Wrapping" in swiftName: - /// - Note: This operation silently wraps around on overflow, like the - /// `${operator}` operator does on `UInt` values. - /// - % end - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThen${swiftName}( - ${label} operand: ${valueType}, - ordering: AtomicUpdateOrdering - ) -> ${valueType} { - switch ordering { -% for (enumOrder, apiOrder, docOrder, llvmOrder, failOrder) in updateOrderings: - case .${enumOrder}: - return _sa_fetch_${builtinName}_${shim_name(llvmOrder)}_${valueType}( - self, operand) -% end - default: - preconditionFailure("Unsupported ordering") - } - } -% end -% end -} -% end -#endif // ATOMICS_NATIVE_BUILTINS diff --git a/Sources/Atomics/Primitives/autogenerated/Primitives.native.swift b/Sources/Atomics/Primitives/autogenerated/Primitives.native.swift index 99b728c..5eaf256 100644 --- a/Sources/Atomics/Primitives/autogenerated/Primitives.native.swift +++ b/Sources/Atomics/Primitives/autogenerated/Primitives.native.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2023 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -18,13 +18,6 @@ // ############################################################################# -// FIXME: The conditionals below have been carefully constructed to -// avoid confusing Swift 5.7; they can be sanitized once we drop support -// for that version. -#if compiler(>=5.9) -#if !ATOMICS_NATIVE_BUILTINS -#error("swift-atomics requires native builtins on Swift 5.9") -#endif import Builtin @_alwaysEmitIntoClient @@ -2453,9 +2446,3 @@ extension UnsafeMutablePointer where Pointee == _AtomicInt128Storage { #else #error("Unexpected pointer bit width") #endif - -#else // compiler(>=5.9) -#if ATOMICS_NATIVE_BUILTINS -#error("swift-atomics requires C shims on Swift versions below 5.9") -#endif -#endif // compiler(>=5.9) diff --git a/Sources/Atomics/Primitives/autogenerated/Primitives.shims.swift b/Sources/Atomics/Primitives/autogenerated/Primitives.shims.swift deleted file mode 100644 index ced9b3b..0000000 --- a/Sources/Atomics/Primitives/autogenerated/Primitives.shims.swift +++ /dev/null @@ -1,2574 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - - -// ############################################################################# -// # # -// # DO NOT EDIT THIS FILE; IT IS AUTOGENERATED. # -// # # -// ############################################################################# - - -#if !ATOMICS_NATIVE_BUILTINS -import _AtomicsShims - -@_alwaysEmitIntoClient -@_transparent -internal func _atomicMemoryFence( - ordering: AtomicUpdateOrdering -) { - switch ordering { - case .relaxed: - break - case .acquiring: - _sa_thread_fence_acquire() - case .releasing: - _sa_thread_fence_release() - case .acquiringAndReleasing: - _sa_thread_fence_acq_rel() - case .sequentiallyConsistent: - _sa_thread_fence_seq_cst() - default: - fatalError("Unsupported ordering") - } -} - -extension UnsafeMutablePointer where Pointee == _AtomicInt8Storage { - /// Atomically loads a word starting at this address with the specified - /// memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicLoad(ordering: AtomicLoadOrdering) -> Int8 { - switch ordering { - case .relaxed: - return _sa_load_relaxed_Int8(self) - case .acquiring: - return _sa_load_acquire_Int8(self) - case .sequentiallyConsistent: - return _sa_load_seq_cst_Int8(self) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicStore( - _ desired: Int8, - ordering: AtomicStoreOrdering - ) { - switch ordering { - case .relaxed: - _sa_store_relaxed_Int8(self, desired) - case .releasing: - _sa_store_release_Int8(self, desired) - case .sequentiallyConsistent: - _sa_store_seq_cst_Int8(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicExchange( - _ desired: Int8, - ordering: AtomicUpdateOrdering - ) -> Int8 { - switch ordering { - case .relaxed: - return _sa_exchange_relaxed_Int8(self, desired) - case .acquiring: - return _sa_exchange_acquire_Int8(self, desired) - case .releasing: - return _sa_exchange_release_Int8(self, desired) - case .acquiringAndReleasing: - return _sa_exchange_acq_rel_Int8(self, desired) - case .sequentiallyConsistent: - return _sa_exchange_seq_cst_Int8(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Perform an atomic compare and exchange operation with the specified memory - /// ordering. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int8, - desired: Int8, - ordering: AtomicUpdateOrdering - ) -> (exchanged: Bool, original: Int8) { - var expected = expected - let exchanged: Bool - switch ordering { - case .relaxed: - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int8( - self, &expected, desired) - case .acquiring: - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int8( - self, &expected, desired) - case .releasing: - exchanged = _sa_cmpxchg_strong_release_relaxed_Int8( - self, &expected, desired) - case .acquiringAndReleasing: - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int8( - self, &expected, desired) - case .sequentiallyConsistent: - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int8( - self, &expected, desired) - default: - fatalError("Unsupported ordering") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int8, - desired: Int8, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int8) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int8( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int8( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int8( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_strong_acquire_relaxed_Int8( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int8( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int8( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_strong_release_relaxed_Int8( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int8( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int8( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_strong_acq_rel_relaxed_Int8( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int8( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int8( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_strong_seq_cst_relaxed_Int8( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_strong_seq_cst_acquire_Int8( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int8( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicWeakCompareExchange( - expected: Int8, - desired: Int8, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int8) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_weak_relaxed_relaxed_Int8( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int8( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int8( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_weak_acquire_relaxed_Int8( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int8( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int8( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_weak_release_relaxed_Int8( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int8( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int8( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_weak_acq_rel_relaxed_Int8( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int8( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int8( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_weak_seq_cst_relaxed_Int8( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_weak_seq_cst_acquire_Int8( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int8( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic wrapping add operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&+` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingIncrement( - by operand: Int8, - ordering: AtomicUpdateOrdering - ) -> Int8 { - switch ordering { - case .relaxed: - return _sa_fetch_add_relaxed_Int8( - self, operand) - case .acquiring: - return _sa_fetch_add_acquire_Int8( - self, operand) - case .releasing: - return _sa_fetch_add_release_Int8( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_add_acq_rel_Int8( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_add_seq_cst_Int8( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic wrapping subtract operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&-` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingDecrement( - by operand: Int8, - ordering: AtomicUpdateOrdering - ) -> Int8 { - switch ordering { - case .relaxed: - return _sa_fetch_sub_relaxed_Int8( - self, operand) - case .acquiring: - return _sa_fetch_sub_acquire_Int8( - self, operand) - case .releasing: - return _sa_fetch_sub_release_Int8( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_sub_acq_rel_Int8( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_sub_seq_cst_Int8( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise AND operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseAnd( - with operand: Int8, - ordering: AtomicUpdateOrdering - ) -> Int8 { - switch ordering { - case .relaxed: - return _sa_fetch_and_relaxed_Int8( - self, operand) - case .acquiring: - return _sa_fetch_and_acquire_Int8( - self, operand) - case .releasing: - return _sa_fetch_and_release_Int8( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_and_acq_rel_Int8( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_and_seq_cst_Int8( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise OR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseOr( - with operand: Int8, - ordering: AtomicUpdateOrdering - ) -> Int8 { - switch ordering { - case .relaxed: - return _sa_fetch_or_relaxed_Int8( - self, operand) - case .acquiring: - return _sa_fetch_or_acquire_Int8( - self, operand) - case .releasing: - return _sa_fetch_or_release_Int8( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_or_acq_rel_Int8( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_or_seq_cst_Int8( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise XOR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseXor( - with operand: Int8, - ordering: AtomicUpdateOrdering - ) -> Int8 { - switch ordering { - case .relaxed: - return _sa_fetch_xor_relaxed_Int8( - self, operand) - case .acquiring: - return _sa_fetch_xor_acquire_Int8( - self, operand) - case .releasing: - return _sa_fetch_xor_release_Int8( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_xor_acq_rel_Int8( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_xor_seq_cst_Int8( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } -} -extension UnsafeMutablePointer where Pointee == _AtomicInt16Storage { - /// Atomically loads a word starting at this address with the specified - /// memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicLoad(ordering: AtomicLoadOrdering) -> Int16 { - switch ordering { - case .relaxed: - return _sa_load_relaxed_Int16(self) - case .acquiring: - return _sa_load_acquire_Int16(self) - case .sequentiallyConsistent: - return _sa_load_seq_cst_Int16(self) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicStore( - _ desired: Int16, - ordering: AtomicStoreOrdering - ) { - switch ordering { - case .relaxed: - _sa_store_relaxed_Int16(self, desired) - case .releasing: - _sa_store_release_Int16(self, desired) - case .sequentiallyConsistent: - _sa_store_seq_cst_Int16(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicExchange( - _ desired: Int16, - ordering: AtomicUpdateOrdering - ) -> Int16 { - switch ordering { - case .relaxed: - return _sa_exchange_relaxed_Int16(self, desired) - case .acquiring: - return _sa_exchange_acquire_Int16(self, desired) - case .releasing: - return _sa_exchange_release_Int16(self, desired) - case .acquiringAndReleasing: - return _sa_exchange_acq_rel_Int16(self, desired) - case .sequentiallyConsistent: - return _sa_exchange_seq_cst_Int16(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Perform an atomic compare and exchange operation with the specified memory - /// ordering. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int16, - desired: Int16, - ordering: AtomicUpdateOrdering - ) -> (exchanged: Bool, original: Int16) { - var expected = expected - let exchanged: Bool - switch ordering { - case .relaxed: - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int16( - self, &expected, desired) - case .acquiring: - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int16( - self, &expected, desired) - case .releasing: - exchanged = _sa_cmpxchg_strong_release_relaxed_Int16( - self, &expected, desired) - case .acquiringAndReleasing: - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int16( - self, &expected, desired) - case .sequentiallyConsistent: - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int16( - self, &expected, desired) - default: - fatalError("Unsupported ordering") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int16, - desired: Int16, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int16) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int16( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int16( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int16( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_strong_acquire_relaxed_Int16( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int16( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int16( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_strong_release_relaxed_Int16( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int16( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int16( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_strong_acq_rel_relaxed_Int16( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int16( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int16( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_strong_seq_cst_relaxed_Int16( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_strong_seq_cst_acquire_Int16( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int16( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicWeakCompareExchange( - expected: Int16, - desired: Int16, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int16) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_weak_relaxed_relaxed_Int16( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int16( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int16( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_weak_acquire_relaxed_Int16( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int16( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int16( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_weak_release_relaxed_Int16( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int16( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int16( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_weak_acq_rel_relaxed_Int16( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int16( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int16( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_weak_seq_cst_relaxed_Int16( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_weak_seq_cst_acquire_Int16( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int16( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic wrapping add operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&+` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingIncrement( - by operand: Int16, - ordering: AtomicUpdateOrdering - ) -> Int16 { - switch ordering { - case .relaxed: - return _sa_fetch_add_relaxed_Int16( - self, operand) - case .acquiring: - return _sa_fetch_add_acquire_Int16( - self, operand) - case .releasing: - return _sa_fetch_add_release_Int16( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_add_acq_rel_Int16( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_add_seq_cst_Int16( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic wrapping subtract operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&-` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingDecrement( - by operand: Int16, - ordering: AtomicUpdateOrdering - ) -> Int16 { - switch ordering { - case .relaxed: - return _sa_fetch_sub_relaxed_Int16( - self, operand) - case .acquiring: - return _sa_fetch_sub_acquire_Int16( - self, operand) - case .releasing: - return _sa_fetch_sub_release_Int16( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_sub_acq_rel_Int16( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_sub_seq_cst_Int16( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise AND operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseAnd( - with operand: Int16, - ordering: AtomicUpdateOrdering - ) -> Int16 { - switch ordering { - case .relaxed: - return _sa_fetch_and_relaxed_Int16( - self, operand) - case .acquiring: - return _sa_fetch_and_acquire_Int16( - self, operand) - case .releasing: - return _sa_fetch_and_release_Int16( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_and_acq_rel_Int16( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_and_seq_cst_Int16( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise OR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseOr( - with operand: Int16, - ordering: AtomicUpdateOrdering - ) -> Int16 { - switch ordering { - case .relaxed: - return _sa_fetch_or_relaxed_Int16( - self, operand) - case .acquiring: - return _sa_fetch_or_acquire_Int16( - self, operand) - case .releasing: - return _sa_fetch_or_release_Int16( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_or_acq_rel_Int16( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_or_seq_cst_Int16( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise XOR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseXor( - with operand: Int16, - ordering: AtomicUpdateOrdering - ) -> Int16 { - switch ordering { - case .relaxed: - return _sa_fetch_xor_relaxed_Int16( - self, operand) - case .acquiring: - return _sa_fetch_xor_acquire_Int16( - self, operand) - case .releasing: - return _sa_fetch_xor_release_Int16( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_xor_acq_rel_Int16( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_xor_seq_cst_Int16( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } -} -extension UnsafeMutablePointer where Pointee == _AtomicInt32Storage { - /// Atomically loads a word starting at this address with the specified - /// memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicLoad(ordering: AtomicLoadOrdering) -> Int32 { - switch ordering { - case .relaxed: - return _sa_load_relaxed_Int32(self) - case .acquiring: - return _sa_load_acquire_Int32(self) - case .sequentiallyConsistent: - return _sa_load_seq_cst_Int32(self) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicStore( - _ desired: Int32, - ordering: AtomicStoreOrdering - ) { - switch ordering { - case .relaxed: - _sa_store_relaxed_Int32(self, desired) - case .releasing: - _sa_store_release_Int32(self, desired) - case .sequentiallyConsistent: - _sa_store_seq_cst_Int32(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicExchange( - _ desired: Int32, - ordering: AtomicUpdateOrdering - ) -> Int32 { - switch ordering { - case .relaxed: - return _sa_exchange_relaxed_Int32(self, desired) - case .acquiring: - return _sa_exchange_acquire_Int32(self, desired) - case .releasing: - return _sa_exchange_release_Int32(self, desired) - case .acquiringAndReleasing: - return _sa_exchange_acq_rel_Int32(self, desired) - case .sequentiallyConsistent: - return _sa_exchange_seq_cst_Int32(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Perform an atomic compare and exchange operation with the specified memory - /// ordering. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int32, - desired: Int32, - ordering: AtomicUpdateOrdering - ) -> (exchanged: Bool, original: Int32) { - var expected = expected - let exchanged: Bool - switch ordering { - case .relaxed: - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int32( - self, &expected, desired) - case .acquiring: - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int32( - self, &expected, desired) - case .releasing: - exchanged = _sa_cmpxchg_strong_release_relaxed_Int32( - self, &expected, desired) - case .acquiringAndReleasing: - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int32( - self, &expected, desired) - case .sequentiallyConsistent: - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int32( - self, &expected, desired) - default: - fatalError("Unsupported ordering") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int32, - desired: Int32, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int32) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int32( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int32( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int32( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_strong_acquire_relaxed_Int32( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int32( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int32( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_strong_release_relaxed_Int32( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int32( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int32( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_strong_acq_rel_relaxed_Int32( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int32( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int32( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_strong_seq_cst_relaxed_Int32( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_strong_seq_cst_acquire_Int32( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int32( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicWeakCompareExchange( - expected: Int32, - desired: Int32, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int32) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_weak_relaxed_relaxed_Int32( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int32( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int32( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_weak_acquire_relaxed_Int32( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int32( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int32( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_weak_release_relaxed_Int32( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int32( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int32( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_weak_acq_rel_relaxed_Int32( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int32( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int32( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_weak_seq_cst_relaxed_Int32( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_weak_seq_cst_acquire_Int32( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int32( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic wrapping add operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&+` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingIncrement( - by operand: Int32, - ordering: AtomicUpdateOrdering - ) -> Int32 { - switch ordering { - case .relaxed: - return _sa_fetch_add_relaxed_Int32( - self, operand) - case .acquiring: - return _sa_fetch_add_acquire_Int32( - self, operand) - case .releasing: - return _sa_fetch_add_release_Int32( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_add_acq_rel_Int32( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_add_seq_cst_Int32( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic wrapping subtract operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&-` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingDecrement( - by operand: Int32, - ordering: AtomicUpdateOrdering - ) -> Int32 { - switch ordering { - case .relaxed: - return _sa_fetch_sub_relaxed_Int32( - self, operand) - case .acquiring: - return _sa_fetch_sub_acquire_Int32( - self, operand) - case .releasing: - return _sa_fetch_sub_release_Int32( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_sub_acq_rel_Int32( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_sub_seq_cst_Int32( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise AND operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseAnd( - with operand: Int32, - ordering: AtomicUpdateOrdering - ) -> Int32 { - switch ordering { - case .relaxed: - return _sa_fetch_and_relaxed_Int32( - self, operand) - case .acquiring: - return _sa_fetch_and_acquire_Int32( - self, operand) - case .releasing: - return _sa_fetch_and_release_Int32( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_and_acq_rel_Int32( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_and_seq_cst_Int32( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise OR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseOr( - with operand: Int32, - ordering: AtomicUpdateOrdering - ) -> Int32 { - switch ordering { - case .relaxed: - return _sa_fetch_or_relaxed_Int32( - self, operand) - case .acquiring: - return _sa_fetch_or_acquire_Int32( - self, operand) - case .releasing: - return _sa_fetch_or_release_Int32( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_or_acq_rel_Int32( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_or_seq_cst_Int32( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise XOR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseXor( - with operand: Int32, - ordering: AtomicUpdateOrdering - ) -> Int32 { - switch ordering { - case .relaxed: - return _sa_fetch_xor_relaxed_Int32( - self, operand) - case .acquiring: - return _sa_fetch_xor_acquire_Int32( - self, operand) - case .releasing: - return _sa_fetch_xor_release_Int32( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_xor_acq_rel_Int32( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_xor_seq_cst_Int32( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } -} -extension UnsafeMutablePointer where Pointee == _AtomicInt64Storage { - /// Atomically loads a word starting at this address with the specified - /// memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicLoad(ordering: AtomicLoadOrdering) -> Int64 { - switch ordering { - case .relaxed: - return _sa_load_relaxed_Int64(self) - case .acquiring: - return _sa_load_acquire_Int64(self) - case .sequentiallyConsistent: - return _sa_load_seq_cst_Int64(self) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicStore( - _ desired: Int64, - ordering: AtomicStoreOrdering - ) { - switch ordering { - case .relaxed: - _sa_store_relaxed_Int64(self, desired) - case .releasing: - _sa_store_release_Int64(self, desired) - case .sequentiallyConsistent: - _sa_store_seq_cst_Int64(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicExchange( - _ desired: Int64, - ordering: AtomicUpdateOrdering - ) -> Int64 { - switch ordering { - case .relaxed: - return _sa_exchange_relaxed_Int64(self, desired) - case .acquiring: - return _sa_exchange_acquire_Int64(self, desired) - case .releasing: - return _sa_exchange_release_Int64(self, desired) - case .acquiringAndReleasing: - return _sa_exchange_acq_rel_Int64(self, desired) - case .sequentiallyConsistent: - return _sa_exchange_seq_cst_Int64(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Perform an atomic compare and exchange operation with the specified memory - /// ordering. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int64, - desired: Int64, - ordering: AtomicUpdateOrdering - ) -> (exchanged: Bool, original: Int64) { - var expected = expected - let exchanged: Bool - switch ordering { - case .relaxed: - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int64( - self, &expected, desired) - case .acquiring: - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int64( - self, &expected, desired) - case .releasing: - exchanged = _sa_cmpxchg_strong_release_relaxed_Int64( - self, &expected, desired) - case .acquiringAndReleasing: - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int64( - self, &expected, desired) - case .sequentiallyConsistent: - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int64( - self, &expected, desired) - default: - fatalError("Unsupported ordering") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int64, - desired: Int64, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int64) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int64( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int64( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int64( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_strong_acquire_relaxed_Int64( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int64( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int64( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_strong_release_relaxed_Int64( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int64( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int64( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_strong_acq_rel_relaxed_Int64( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int64( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int64( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_strong_seq_cst_relaxed_Int64( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_strong_seq_cst_acquire_Int64( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int64( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicWeakCompareExchange( - expected: Int64, - desired: Int64, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int64) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_weak_relaxed_relaxed_Int64( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int64( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int64( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_weak_acquire_relaxed_Int64( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int64( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int64( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_weak_release_relaxed_Int64( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int64( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int64( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_weak_acq_rel_relaxed_Int64( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int64( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int64( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_weak_seq_cst_relaxed_Int64( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_weak_seq_cst_acquire_Int64( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int64( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic wrapping add operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&+` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingIncrement( - by operand: Int64, - ordering: AtomicUpdateOrdering - ) -> Int64 { - switch ordering { - case .relaxed: - return _sa_fetch_add_relaxed_Int64( - self, operand) - case .acquiring: - return _sa_fetch_add_acquire_Int64( - self, operand) - case .releasing: - return _sa_fetch_add_release_Int64( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_add_acq_rel_Int64( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_add_seq_cst_Int64( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic wrapping subtract operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&-` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingDecrement( - by operand: Int64, - ordering: AtomicUpdateOrdering - ) -> Int64 { - switch ordering { - case .relaxed: - return _sa_fetch_sub_relaxed_Int64( - self, operand) - case .acquiring: - return _sa_fetch_sub_acquire_Int64( - self, operand) - case .releasing: - return _sa_fetch_sub_release_Int64( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_sub_acq_rel_Int64( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_sub_seq_cst_Int64( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise AND operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseAnd( - with operand: Int64, - ordering: AtomicUpdateOrdering - ) -> Int64 { - switch ordering { - case .relaxed: - return _sa_fetch_and_relaxed_Int64( - self, operand) - case .acquiring: - return _sa_fetch_and_acquire_Int64( - self, operand) - case .releasing: - return _sa_fetch_and_release_Int64( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_and_acq_rel_Int64( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_and_seq_cst_Int64( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise OR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseOr( - with operand: Int64, - ordering: AtomicUpdateOrdering - ) -> Int64 { - switch ordering { - case .relaxed: - return _sa_fetch_or_relaxed_Int64( - self, operand) - case .acquiring: - return _sa_fetch_or_acquire_Int64( - self, operand) - case .releasing: - return _sa_fetch_or_release_Int64( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_or_acq_rel_Int64( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_or_seq_cst_Int64( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise XOR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseXor( - with operand: Int64, - ordering: AtomicUpdateOrdering - ) -> Int64 { - switch ordering { - case .relaxed: - return _sa_fetch_xor_relaxed_Int64( - self, operand) - case .acquiring: - return _sa_fetch_xor_acquire_Int64( - self, operand) - case .releasing: - return _sa_fetch_xor_release_Int64( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_xor_acq_rel_Int64( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_xor_seq_cst_Int64( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } -} -extension UnsafeMutablePointer where Pointee == _AtomicIntStorage { - /// Atomically loads a word starting at this address with the specified - /// memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicLoad(ordering: AtomicLoadOrdering) -> Int { - switch ordering { - case .relaxed: - return _sa_load_relaxed_Int(self) - case .acquiring: - return _sa_load_acquire_Int(self) - case .sequentiallyConsistent: - return _sa_load_seq_cst_Int(self) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicStore( - _ desired: Int, - ordering: AtomicStoreOrdering - ) { - switch ordering { - case .relaxed: - _sa_store_relaxed_Int(self, desired) - case .releasing: - _sa_store_release_Int(self, desired) - case .sequentiallyConsistent: - _sa_store_seq_cst_Int(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicExchange( - _ desired: Int, - ordering: AtomicUpdateOrdering - ) -> Int { - switch ordering { - case .relaxed: - return _sa_exchange_relaxed_Int(self, desired) - case .acquiring: - return _sa_exchange_acquire_Int(self, desired) - case .releasing: - return _sa_exchange_release_Int(self, desired) - case .acquiringAndReleasing: - return _sa_exchange_acq_rel_Int(self, desired) - case .sequentiallyConsistent: - return _sa_exchange_seq_cst_Int(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Perform an atomic compare and exchange operation with the specified memory - /// ordering. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int, - desired: Int, - ordering: AtomicUpdateOrdering - ) -> (exchanged: Bool, original: Int) { - var expected = expected - let exchanged: Bool - switch ordering { - case .relaxed: - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int( - self, &expected, desired) - case .acquiring: - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int( - self, &expected, desired) - case .releasing: - exchanged = _sa_cmpxchg_strong_release_relaxed_Int( - self, &expected, desired) - case .acquiringAndReleasing: - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int( - self, &expected, desired) - case .sequentiallyConsistent: - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int( - self, &expected, desired) - default: - fatalError("Unsupported ordering") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: Int, - desired: Int, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_Int( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_strong_acquire_relaxed_Int( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_Int( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_strong_release_relaxed_Int( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_strong_acq_rel_relaxed_Int( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_Int( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_strong_seq_cst_relaxed_Int( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_strong_seq_cst_acquire_Int( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_Int( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicWeakCompareExchange( - expected: Int, - desired: Int, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: Int) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_weak_relaxed_relaxed_Int( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_weak_acquire_relaxed_Int( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_Int( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_weak_release_relaxed_Int( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_weak_acq_rel_relaxed_Int( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_Int( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_weak_seq_cst_relaxed_Int( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_weak_seq_cst_acquire_Int( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_Int( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic wrapping add operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&+` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingIncrement( - by operand: Int, - ordering: AtomicUpdateOrdering - ) -> Int { - switch ordering { - case .relaxed: - return _sa_fetch_add_relaxed_Int( - self, operand) - case .acquiring: - return _sa_fetch_add_acquire_Int( - self, operand) - case .releasing: - return _sa_fetch_add_release_Int( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_add_acq_rel_Int( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_add_seq_cst_Int( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic wrapping subtract operation and return the new value, - /// with the specified memory ordering. - /// - /// - Note: This operation silently wraps around on overflow, like the - /// `&-` operator does on `UInt` values. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenWrappingDecrement( - by operand: Int, - ordering: AtomicUpdateOrdering - ) -> Int { - switch ordering { - case .relaxed: - return _sa_fetch_sub_relaxed_Int( - self, operand) - case .acquiring: - return _sa_fetch_sub_acquire_Int( - self, operand) - case .releasing: - return _sa_fetch_sub_release_Int( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_sub_acq_rel_Int( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_sub_seq_cst_Int( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise AND operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseAnd( - with operand: Int, - ordering: AtomicUpdateOrdering - ) -> Int { - switch ordering { - case .relaxed: - return _sa_fetch_and_relaxed_Int( - self, operand) - case .acquiring: - return _sa_fetch_and_acquire_Int( - self, operand) - case .releasing: - return _sa_fetch_and_release_Int( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_and_acq_rel_Int( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_and_seq_cst_Int( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise OR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseOr( - with operand: Int, - ordering: AtomicUpdateOrdering - ) -> Int { - switch ordering { - case .relaxed: - return _sa_fetch_or_relaxed_Int( - self, operand) - case .acquiring: - return _sa_fetch_or_acquire_Int( - self, operand) - case .releasing: - return _sa_fetch_or_release_Int( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_or_acq_rel_Int( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_or_seq_cst_Int( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } - /// Perform an atomic bitwise XOR operation and return the new value, - /// with the specified memory ordering. - /// - /// - Returns: The original value before the operation. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal - func _atomicLoadThenBitwiseXor( - with operand: Int, - ordering: AtomicUpdateOrdering - ) -> Int { - switch ordering { - case .relaxed: - return _sa_fetch_xor_relaxed_Int( - self, operand) - case .acquiring: - return _sa_fetch_xor_acquire_Int( - self, operand) - case .releasing: - return _sa_fetch_xor_release_Int( - self, operand) - case .acquiringAndReleasing: - return _sa_fetch_xor_acq_rel_Int( - self, operand) - case .sequentiallyConsistent: - return _sa_fetch_xor_seq_cst_Int( - self, operand) - default: - preconditionFailure("Unsupported ordering") - } - } -} -extension UnsafeMutablePointer where Pointee == _AtomicDoubleWordStorage { - /// Atomically loads a word starting at this address with the specified - /// memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicLoad(ordering: AtomicLoadOrdering) -> DoubleWord { - switch ordering { - case .relaxed: - return _sa_load_relaxed_DoubleWord(self) - case .acquiring: - return _sa_load_acquire_DoubleWord(self) - case .sequentiallyConsistent: - return _sa_load_seq_cst_DoubleWord(self) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - @usableFromInline - internal func _atomicStore( - _ desired: DoubleWord, - ordering: AtomicStoreOrdering - ) { - switch ordering { - case .relaxed: - _sa_store_relaxed_DoubleWord(self, desired) - case .releasing: - _sa_store_release_DoubleWord(self, desired) - case .sequentiallyConsistent: - _sa_store_seq_cst_DoubleWord(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Atomically stores the specified value starting at the memory referenced by - /// this pointer, with the specified memory ordering. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicExchange( - _ desired: DoubleWord, - ordering: AtomicUpdateOrdering - ) -> DoubleWord { - switch ordering { - case .relaxed: - return _sa_exchange_relaxed_DoubleWord(self, desired) - case .acquiring: - return _sa_exchange_acquire_DoubleWord(self, desired) - case .releasing: - return _sa_exchange_release_DoubleWord(self, desired) - case .acquiringAndReleasing: - return _sa_exchange_acq_rel_DoubleWord(self, desired) - case .sequentiallyConsistent: - return _sa_exchange_seq_cst_DoubleWord(self, desired) - default: - fatalError("Unsupported ordering") - } - } - - /// Perform an atomic compare and exchange operation with the specified memory - /// ordering. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: DoubleWord, - desired: DoubleWord, - ordering: AtomicUpdateOrdering - ) -> (exchanged: Bool, original: DoubleWord) { - var expected = expected - let exchanged: Bool - switch ordering { - case .relaxed: - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_DoubleWord( - self, &expected, desired) - case .acquiring: - exchanged = _sa_cmpxchg_strong_acquire_acquire_DoubleWord( - self, &expected, desired) - case .releasing: - exchanged = _sa_cmpxchg_strong_release_relaxed_DoubleWord( - self, &expected, desired) - case .acquiringAndReleasing: - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_DoubleWord( - self, &expected, desired) - case .sequentiallyConsistent: - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - default: - fatalError("Unsupported ordering") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicCompareExchange( - expected: DoubleWord, - desired: DoubleWord, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: DoubleWord) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_strong_relaxed_relaxed_DoubleWord( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_DoubleWord( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_strong_acquire_relaxed_DoubleWord( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_strong_acquire_acquire_DoubleWord( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_strong_release_relaxed_DoubleWord( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_DoubleWord( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_strong_acq_rel_relaxed_DoubleWord( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_strong_acq_rel_acquire_DoubleWord( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_strong_seq_cst_relaxed_DoubleWord( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_strong_seq_cst_acquire_DoubleWord( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_strong_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - - /// Perform an atomic compare and exchange operation with the specified - /// success/failure memory orderings. - /// - /// This operation is equivalent to the following pseudocode: - /// - /// ``` - /// atomic(self, ordering, failureOrdering) { currentValue in - /// let original = currentValue - /// guard original == expected else { return (false, original) } - /// currentValue = desired - /// return (true, original) - /// } - /// ``` - /// - /// The `ordering` argument specifies the memory ordering to use when the - /// operation manages to update the current value, while `failureOrdering` - /// will be used when the operation leaves the value intact. - @_semantics("atomics.requires_constant_orderings") - @_alwaysEmitIntoClient - @_transparent // Debug performance - public func _atomicWeakCompareExchange( - expected: DoubleWord, - desired: DoubleWord, - successOrdering: AtomicUpdateOrdering, - failureOrdering: AtomicLoadOrdering - ) -> (exchanged: Bool, original: DoubleWord) { - // FIXME: LLVM doesn't support arbitrary ordering combinations - // yet, so upgrade the success ordering when necessary so that it - // is at least as "strong" as the failure case. - var expected = expected - let exchanged: Bool - switch (successOrdering, failureOrdering) { - case (.relaxed, .relaxed): - exchanged = _sa_cmpxchg_weak_relaxed_relaxed_DoubleWord( - self, &expected, desired) - case (.relaxed, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_DoubleWord( - self, &expected, desired) - case (.relaxed, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - case (.acquiring, .relaxed): - exchanged = _sa_cmpxchg_weak_acquire_relaxed_DoubleWord( - self, &expected, desired) - case (.acquiring, .acquiring): - exchanged = _sa_cmpxchg_weak_acquire_acquire_DoubleWord( - self, &expected, desired) - case (.acquiring, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - case (.releasing, .relaxed): - exchanged = _sa_cmpxchg_weak_release_relaxed_DoubleWord( - self, &expected, desired) - case (.releasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_DoubleWord( - self, &expected, desired) - case (.releasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - case (.acquiringAndReleasing, .relaxed): - exchanged = _sa_cmpxchg_weak_acq_rel_relaxed_DoubleWord( - self, &expected, desired) - case (.acquiringAndReleasing, .acquiring): - exchanged = _sa_cmpxchg_weak_acq_rel_acquire_DoubleWord( - self, &expected, desired) - case (.acquiringAndReleasing, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - case (.sequentiallyConsistent, .relaxed): - exchanged = _sa_cmpxchg_weak_seq_cst_relaxed_DoubleWord( - self, &expected, desired) - case (.sequentiallyConsistent, .acquiring): - exchanged = _sa_cmpxchg_weak_seq_cst_acquire_DoubleWord( - self, &expected, desired) - case (.sequentiallyConsistent, .sequentiallyConsistent): - exchanged = _sa_cmpxchg_weak_seq_cst_seq_cst_DoubleWord( - self, &expected, desired) - default: - preconditionFailure("Unsupported orderings") - } - return (exchanged, expected) - } - -} -#endif // ATOMICS_NATIVE_BUILTINS diff --git a/Sources/Atomics/Protocols/AtomicReference.swift b/Sources/Atomics/Protocols/AtomicReference.swift index ce537af..61b4e80 100644 --- a/Sources/Atomics/Protocols/AtomicReference.swift +++ b/Sources/Atomics/Protocols/AtomicReference.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,10 +10,6 @@ // //===----------------------------------------------------------------------===// -#if !ATOMICS_NATIVE_BUILTINS -import _AtomicsShims -#endif - /// A class type that supports atomic strong references. /// /// class MyObject: AtomicReference {} diff --git a/Sources/Atomics/Types/DoubleWord.swift b/Sources/Atomics/Types/DoubleWord.swift index 5f51af7..f2d37b4 100644 --- a/Sources/Atomics/Types/DoubleWord.swift +++ b/Sources/Atomics/Types/DoubleWord.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,14 +10,6 @@ // //===----------------------------------------------------------------------===// -// FIXME: The conditionals below have been carefully constructed to -// avoid confusing Swift 5.7; they can be sanitized once we drop support -// for that version. -#if compiler(>=5.9) -#if !ATOMICS_NATIVE_BUILTINS -#error("swift-atomics requires native builtins on Swift 5.9") -#endif - import Builtin #if _pointerBitWidth(_32) @@ -70,15 +62,6 @@ extension DoubleWord { } } -#else // compiler(>=5.9) - -#if ATOMICS_NATIVE_BUILTINS -#error("swift-atomics requires C shims on Swift versions below 5.9") -#endif -import _AtomicsShims -public typealias DoubleWord = _AtomicsShims.DoubleWord -#endif // compiler(>=5.9) - extension DoubleWord { /// Initialize a new `DoubleWord` value given its high- and /// low-order words. diff --git a/Sources/Atomics/Unmanaged extensions.swift b/Sources/Atomics/Unmanaged extensions.swift index c664959..b4b1a44 100644 --- a/Sources/Atomics/Unmanaged extensions.swift +++ b/Sources/Atomics/Unmanaged extensions.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -17,12 +17,12 @@ internal func _sa_retain_n(_ object: UnsafeMutableRawPointer, _ delta: UInt32) @_silgen_name("_sa_release_n") internal func _sa_release_n(_ object: UnsafeMutableRawPointer, _ delta: UInt32) #else -// Note: with ATOMICS_NATIVE_BUILTINS, this file contains the last remaining -// import of the shims module, and we only need it to get the declarations for -// _sa_retain_n/_sa_release_n. The import is unfortunately still problematic; -// these functions need to be moved into the stdlib or (preferably) we need -// a compiler-level fix for https://github.com/apple/swift/issues/56105 to get rid -// of it. +// Note: This file contains the last remaining import of the shims +// module, and we only need it to get the declarations for +// _sa_retain_n/_sa_release_n. The import is unfortunately still +// problematic; these functions need to be moved into the stdlib or +// (preferably) we need a compiler-level fix for +// https://github.com/apple/swift/issues/56105 to get rid of it. // // Hiding the import using @_implementationOnly is not possible unless // Swift's library evolution dialect is enabled. (Which we cannot easily test diff --git a/Sources/_AtomicsShims/include/_AtomicsShims.h b/Sources/_AtomicsShims/include/_AtomicsShims.h index 79d2811..348e749 100644 --- a/Sources/_AtomicsShims/include/_AtomicsShims.h +++ b/Sources/_AtomicsShims/include/_AtomicsShims.h @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -41,204 +41,6 @@ # endif #endif -// Swift-importable shims for C atomics. -// -// Swift cannot import C's atomic types or any operations over them, so we need -// to meticulously wrap all of them in tiny importable types and functions. -// -// This file defines an atomic storage representation and 56 atomic operations -// for each of the 10 standard integer types in the Standard Library, as well as -// Bool and a double-word integer type. To prevent us from having to manually -// write/maintain a thousand or so functions, we use the C preprocessor to stamp -// these out. -// -// FIXME: Upgrading from the preprocessor to gyb would perhaps make things more -// readable here. - - -// The atomic primitives are only needed when this is compiled using Swift's -// Clang Importer. This allows us to continue reling on some Clang extensions -// (see https://github.com/apple/swift-atomics/issues/37). -#if !defined(ATOMICS_NATIVE_BUILTINS) && defined(__swift__) && !defined(__cplusplus) -# include - -// Atomic fences -#define SWIFTATOMIC_THREAD_FENCE_FN(order) \ - SWIFTATOMIC_INLINE void _sa_thread_fence_##order(void) \ - { \ - atomic_thread_fence(memory_order_##order); \ - } - -SWIFTATOMIC_THREAD_FENCE_FN(acquire) -SWIFTATOMIC_THREAD_FENCE_FN(release) -SWIFTATOMIC_THREAD_FENCE_FN(acq_rel) -SWIFTATOMIC_THREAD_FENCE_FN(seq_cst) - -// Definition of an atomic storage type. -#define SWIFTATOMIC_STORAGE_TYPE(swiftType, cType) \ - typedef struct { \ - _Atomic(cType) value; \ - } _sa_##swiftType \ - SWIFTATOMIC_SWIFT_NAME(_Atomic##swiftType##Storage); - -// Storage value initializer -#define SWIFTATOMIC_PREPARE_FN(swiftType, cType) \ - SWIFTATOMIC_INLINE \ - _sa_##swiftType _sa_prepare_##swiftType(cType value) \ - { \ - _sa_##swiftType storage = { value }; \ - assert(atomic_is_lock_free(&storage.value)); \ - return storage; \ - } - -// Storage value disposal function -#define SWIFTATOMIC_DISPOSE_FN(swiftType, cType) \ - SWIFTATOMIC_INLINE \ - cType _sa_dispose_##swiftType(_sa_##swiftType storage) \ - { \ - return storage.value; \ - } - -// Atomic load -#define SWIFTATOMIC_LOAD_FN(swiftType, cType, order) \ - SWIFTATOMIC_INLINE \ - cType _sa_load_##order##_##swiftType(_sa_##swiftType *ptr) \ - { \ - return atomic_load_explicit( \ - &ptr->value, memory_order_##order); \ - } - -// Atomic store -#define SWIFTATOMIC_STORE_FN(swiftType, cType, order) \ - SWIFTATOMIC_INLINE \ - void _sa_store_##order##_##swiftType( \ - _sa_##swiftType *ptr, \ - cType desired) \ - { \ - atomic_store_explicit( \ - &ptr->value, desired, memory_order_##order); \ - } - -// Atomic exchange -#define SWIFTATOMIC_EXCHANGE_FN(swiftType, cType, order) \ - SWIFTATOMIC_INLINE \ - cType _sa_exchange_##order##_##swiftType( \ - _sa_##swiftType *ptr, \ - cType desired) \ - { \ - return atomic_exchange_explicit( \ - &ptr->value, desired, memory_order_##order); \ - } - -// Atomic compare/exchange -#define SWIFTATOMIC_CMPXCHG_FN(_kind, swiftType, cType, succ, fail) \ - SWIFTATOMIC_INLINE \ - bool \ - _sa_cmpxchg_##_kind##_##succ##_##fail##_##swiftType( \ - _sa_##swiftType *ptr, \ - cType *expected, \ - cType desired) \ - { \ - return atomic_compare_exchange_##_kind##_explicit( \ - &ptr->value, \ - expected, \ - desired, \ - memory_order_##succ, \ - memory_order_##fail); \ - } - -// Atomic integer operations -#define SWIFTATOMIC_INTEGER_FN(op, swiftType, cType, order) \ - SWIFTATOMIC_INLINE \ - cType _sa_fetch_##op##_##order##_##swiftType( \ - _sa_##swiftType *ptr, \ - cType operand) \ - { \ - return atomic_fetch_##op##_explicit( \ - &ptr->value, operand, memory_order_##order); \ - } - -// Functions for each supported operation + memory ordering combination -#define SWIFTATOMIC_STORE_FNS(swiftType, cType) \ - SWIFTATOMIC_STORE_FN(swiftType, cType, relaxed) \ - SWIFTATOMIC_STORE_FN(swiftType, cType, release) \ - SWIFTATOMIC_STORE_FN(swiftType, cType, seq_cst) - -#define SWIFTATOMIC_LOAD_FNS(swiftType, cType) \ - SWIFTATOMIC_LOAD_FN(swiftType, cType, relaxed) \ - SWIFTATOMIC_LOAD_FN(swiftType, cType, acquire) \ - SWIFTATOMIC_LOAD_FN(swiftType, cType, seq_cst) - -#define SWIFTATOMIC_EXCHANGE_FNS(swiftType, cType) \ - SWIFTATOMIC_EXCHANGE_FN(swiftType, cType, relaxed) \ - SWIFTATOMIC_EXCHANGE_FN(swiftType, cType, acquire) \ - SWIFTATOMIC_EXCHANGE_FN(swiftType, cType, release) \ - SWIFTATOMIC_EXCHANGE_FN(swiftType, cType, acq_rel) \ - SWIFTATOMIC_EXCHANGE_FN(swiftType, cType, seq_cst) - -#define SWIFTATOMIC_CMPXCHG_FNS(kind, swiftType, cType) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, relaxed, relaxed) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, acquire, relaxed) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, release, relaxed) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, acq_rel, relaxed) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, seq_cst, relaxed) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, acquire, acquire) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, acq_rel, acquire) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, seq_cst, acquire) \ - SWIFTATOMIC_CMPXCHG_FN(kind, swiftType, cType, seq_cst, seq_cst) - -#define SWIFTATOMIC_INTEGER_FNS(op, swiftType, cType) \ - SWIFTATOMIC_INTEGER_FN(op, swiftType, cType, relaxed) \ - SWIFTATOMIC_INTEGER_FN(op, swiftType, cType, acquire) \ - SWIFTATOMIC_INTEGER_FN(op, swiftType, cType, release) \ - SWIFTATOMIC_INTEGER_FN(op, swiftType, cType, acq_rel) \ - SWIFTATOMIC_INTEGER_FN(op, swiftType, cType, seq_cst) - -#define SWIFTATOMIC_DEFINE_TYPE(swiftType, cType) \ - SWIFTATOMIC_STORAGE_TYPE(swiftType, cType) \ - SWIFTATOMIC_PREPARE_FN(swiftType, cType) \ - SWIFTATOMIC_DISPOSE_FN(swiftType, cType) \ - SWIFTATOMIC_LOAD_FNS(swiftType, cType) \ - SWIFTATOMIC_STORE_FNS(swiftType, cType) \ - SWIFTATOMIC_EXCHANGE_FNS(swiftType, cType) \ - SWIFTATOMIC_CMPXCHG_FNS(strong, swiftType, cType) \ - SWIFTATOMIC_CMPXCHG_FNS(weak, swiftType, cType) - -#define SWIFTATOMIC_DEFINE_INTEGER_TYPE(swiftType, cType) \ - SWIFTATOMIC_DEFINE_TYPE(swiftType, cType) \ - SWIFTATOMIC_INTEGER_FNS(add, swiftType, cType) \ - SWIFTATOMIC_INTEGER_FNS(sub, swiftType, cType) \ - SWIFTATOMIC_INTEGER_FNS(or, swiftType, cType) \ - SWIFTATOMIC_INTEGER_FNS(xor, swiftType, cType) \ - SWIFTATOMIC_INTEGER_FNS(and, swiftType, cType) - -// All known integer types -SWIFTATOMIC_DEFINE_INTEGER_TYPE(Int, intptr_t) -SWIFTATOMIC_DEFINE_INTEGER_TYPE(Int8, int8_t) -SWIFTATOMIC_DEFINE_INTEGER_TYPE(Int16, int16_t) -SWIFTATOMIC_DEFINE_INTEGER_TYPE(Int32, int32_t) -SWIFTATOMIC_DEFINE_INTEGER_TYPE(Int64, int64_t) - -// Double wide atomics - -#if __SIZEOF_POINTER__ == 8 -# define SWIFTATOMIC_DWORD_ALIGNMENT SWIFTATOMIC_ALIGNED(16) -#elif __SIZEOF_POINTER__ == 4 -# define SWIFTATOMIC_DWORD_ALIGNMENT SWIFTATOMIC_ALIGNED(8) -#else -# error "Unsupported Pointer Size" -#endif - -struct _sa_dword { - uintptr_t first; - uintptr_t second; -} SWIFTATOMIC_DWORD_ALIGNMENT SWIFTATOMIC_SWIFT_NAME(DoubleWord); -typedef struct _sa_dword _sa_dword; - -SWIFTATOMIC_DEFINE_TYPE(DoubleWord, _sa_dword) - -#endif //!defined(ATOMICS_NATIVE_BUILTINS) && defined(__swift__) && !defined(__cplusplus) - #if SWIFTATOMIC_SINGLE_MODULE // In the single-module configuration, declare _sa_retain_n/_sa_release_n with // the Swift calling convention, so that they can be easily picked up with diff --git a/Tests/AtomicsTests/Basics/BasicTestSupport.swift b/Tests/AtomicsTests/Basics/BasicTestSupport.swift index 8758220..765bf6f 100644 --- a/Tests/AtomicsTests/Basics/BasicTestSupport.swift +++ b/Tests/AtomicsTests/Basics/BasicTestSupport.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Atomics open source project // -// Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -12,11 +12,19 @@ import Atomics +#if compiler(>=6.0) +extension Unmanaged: @retroactive Equatable { // FIXME: This is terrible + public static func ==(left: Self, right: Self) -> Bool { + left.toOpaque() == right.toOpaque() + } +} +#else extension Unmanaged: Equatable { // FIXME: This is terrible public static func ==(left: Self, right: Self) -> Bool { left.toOpaque() == right.toOpaque() } } +#endif struct Foo: Equatable, CustomStringConvertible { var value: Int diff --git a/Utilities/gyb_utils.py b/Utilities/gyb_utils.py index 93a177f..7075b18 100644 --- a/Utilities/gyb_utils.py +++ b/Utilities/gyb_utils.py @@ -2,7 +2,7 @@ # # This source file is part of the Swift.org open source project # -# Copyright (c) 2020 - 2023 Apple Inc. and the Swift project authors +# Copyright (c) 2020 - 2025 Apple Inc. and the Swift project authors # Licensed under Apache License v2.0 with Runtime Library Exception # # See https://swift.org/LICENSE.txt for license information @@ -137,5 +137,3 @@ def lowerFirst(str): def argLabel(label): return label + ": " if label != "_" else "" - -ptrBitWidth32 = "(compiler(>=5.9) && _pointerBitWidth(_32)) || (compiler(<5.9) && (arch(i386) || arch(arm) || arch(arm64_32) || arch(wasm32)))" diff --git a/Xcode/README.md b/Xcode/README.md index 4c74b79..275bb20 100644 --- a/Xcode/README.md +++ b/Xcode/README.md @@ -1,5 +1,5 @@ # Xcode build files -The project file here can be used to build a variant of this package with Xcode. The project file is a regular Xcode project that builds the code base using the ATOMICS_NATIVE_BUILTINS configuration, producing a single framework bundle. Build settings are entirely configured via the provided xcconfig files. +The project file here can be used to build a variant of this package with Xcode. The project file is a regular Xcode project that builds the code base producing a single framework bundle. Build settings are entirely configured via the provided xcconfig files. Beware! The contents of this directory are not source stable. They are provided as is, with no compatibility promises across package releases. Future versions of this package can arbitrarily change these files or remove them, without any advance notice. (This can include patch releases.) diff --git a/Xcode/Shared.xcconfig b/Xcode/Shared.xcconfig index 9968527..0af13fa 100644 --- a/Xcode/Shared.xcconfig +++ b/Xcode/Shared.xcconfig @@ -20,8 +20,8 @@ CODE_SIGN_IDENTITY[sdk=appletvos*] = "iOS Developer" SWIFT_VERSION = 5.5 ONLY_ACTIVE_ARCH[config=Debug] = YES -SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) ATOMICS_SINGLE_MODULE ATOMICS_NATIVE_BUILTINS -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) ATOMICS_SINGLE_MODULE=1 ATOMICS_NATIVE_BUILTINS=1 +SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) ATOMICS_SINGLE_MODULE +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) ATOMICS_SINGLE_MODULE=1 SWIFT_COMPILATION_MODE[config=Release] = wholemodule SWIFT_COMPILATION_MODE[config=Debug] = singlefile