2
2
//
3
3
// This source file is part of the Swift Atomics open source project
4
4
//
5
- // Copyright (c) 2023 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -14,15 +14,19 @@ import Builtin
14
14
15
15
% from SwiftAtomics import *
16
16
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"
18
21
19
22
//===----------------------------------------------------------------------===//
20
23
// ${intType} AtomicRepresentable conformance
21
24
//===----------------------------------------------------------------------===//
22
25
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
26
30
27
31
@available(SwiftStdlib 6.0, *)
28
32
extension ${intType}: AtomicRepresentable {
@@ -107,7 +111,7 @@ extension Atomic where Value == ${intType} {
107
111
@_alwaysEmitIntoClient
108
112
@_transparent
109
113
public func ${lowerFirst(name)}(
110
- _ operand: ${intType}${" = 1" if "crement" in name else ""} ,
114
+ _ operand: ${intType},
111
115
ordering: AtomicUpdateOrdering
112
116
) -> (oldValue: ${intType}, newValue: ${intType}) {
113
117
let original = switch ordering {
@@ -128,7 +132,7 @@ extension Atomic where Value == ${intType} {
128
132
#error("Unsupported platform")
129
133
#endif
130
134
% else:
131
- Builtin.atomicrmw_${atomicOperationName(intType, builtinName)}_${llvmOrder}_${builtinInt }(
135
+ Builtin.atomicrmw_${atomicOperationName(intType, builtinName)}_${llvmOrder}_Int${bits }(
132
136
rawAddress,
133
137
operand._value
134
138
)
@@ -231,8 +235,9 @@ extension Atomic where Value == ${intType} {
231
235
}
232
236
}
233
237
234
- % if intType == "Int64" or intType == "UInt64 ":
235
- #endif
236
- % end
238
+ % if bits != " ":
239
+ #endif // _hasAtomicBitWidth
240
+ % end
237
241
238
242
% end
243
+ % end
0 commit comments