22//
33// This source file is part of the Swift Atomics open source project
44//
5- // Copyright (c) 2023 Apple Inc. and the Swift project authors
5+ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors
66// Licensed under Apache License v2.0 with Runtime Library Exception
77//
88// See https://swift.org/LICENSE.txt for license information
@@ -14,15 +14,19 @@ import Builtin
1414
1515% from SwiftAtomics import *
1616
17- % for (intType, intStorage, builtinInt) in intTypes:
17+ % for U in ["", "U"]:
18+ % for bits in atomicBits:
19+ % intType = U + "Int" + bits
20+ % intStorage = "_Atomic" + bits + "BitStorage"
1821
1922//===----------------------------------------------------------------------===//
2023// ${intType} AtomicRepresentable conformance
2124//===----------------------------------------------------------------------===//
2225
23- % if intType == "Int64" or intType == "UInt64":
24- #if (_pointerBitWidth(_32) && _hasAtomicBitWidth(_64)) || _pointerBitWidth(_64)
25- % end
26+ % if bits != "":
27+ % # Assume that everyone has word-sized atomics, but check for the rest
28+ #if _hasAtomicBitWidth(_${bits})
29+ % end
2630
2731@available(SwiftStdlib 6.0, *)
2832extension ${intType}: AtomicRepresentable {
@@ -107,7 +111,7 @@ extension Atomic where Value == ${intType} {
107111 @_alwaysEmitIntoClient
108112 @_transparent
109113 public func ${lowerFirst(name)}(
110- _ operand: ${intType}${" = 1" if "crement" in name else ""} ,
114+ _ operand: ${intType},
111115 ordering: AtomicUpdateOrdering
112116 ) -> (oldValue: ${intType}, newValue: ${intType}) {
113117 let original = switch ordering {
@@ -128,7 +132,7 @@ extension Atomic where Value == ${intType} {
128132#error("Unsupported platform")
129133#endif
130134% else:
131- Builtin.atomicrmw_${atomicOperationName(intType, builtinName)}_${llvmOrder}_${builtinInt }(
135+ Builtin.atomicrmw_${atomicOperationName(intType, builtinName)}_${llvmOrder}_Int${bits }(
132136 rawAddress,
133137 operand._value
134138 )
@@ -231,8 +235,9 @@ extension Atomic where Value == ${intType} {
231235 }
232236}
233237
234- % if intType == "Int64" or intType == "UInt64 ":
235- #endif
236- % end
238+ % if bits != " ":
239+ #endif // _hasAtomicBitWidth
240+ % end
237241
238242% end
243+ % end
0 commit comments