mirror of
https://github.com/apple/swift-atomics
synced 2026-11-22 04:20:39 +00:00
Avoid confusing Swift 5.7 with _pointerBitWidth conditionals
#if conditional parsing is evidently broken in 5.7, and it gets confused unless things are arranged just right. Things seem to work as long as the `compiler(>=5.9)` conditional is put on its own `#if` construct on the topmost level — so let’s do that for now.
This commit is contained in:
3 files changed
+46
-15
No files matched your search
@@ -15,7 +15,13 @@
|
||||
}%
|
||||
${autogenerated_warning()}
|
||||
|
||||
#if ATOMICS_NATIVE_BUILTINS
|
||||
// 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
|
||||
@@ -39,7 +45,7 @@ internal func _atomicMemoryFence(
|
||||
% for (swiftType, builtinType, alignment) in nativePrimitives:
|
||||
|
||||
% if builtinType == "Int128":
|
||||
#if compiler(>=5.9) && _pointerBitWidth(_64)
|
||||
#if _pointerBitWidth(_64)
|
||||
% end
|
||||
@usableFromInline
|
||||
@frozen
|
||||
@@ -267,14 +273,18 @@ extension UnsafeMutablePointer where Pointee == ${swiftType} {
|
||||
% end
|
||||
% end
|
||||
|
||||
#if compiler(>=5.9) && _pointerBitWidth(_64)
|
||||
#if _pointerBitWidth(_64)
|
||||
@usableFromInline internal typealias _AtomicIntStorage = _AtomicInt64Storage
|
||||
@usableFromInline internal typealias _AtomicDoubleWordStorage = _AtomicInt128Storage
|
||||
#elseif compiler(>=5.9) && _pointerBitWidth(_32)
|
||||
#elseif _pointerBitWidth(_32)
|
||||
@usableFromInline internal typealias _AtomicIntStorage = _AtomicInt32Storage
|
||||
@usableFromInline internal typealias _AtomicDoubleWordStorage = _AtomicInt64Storage
|
||||
#else
|
||||
#error("Unexpected pointer bit width")
|
||||
#endif
|
||||
|
||||
#endif // ATOMICS_NATIVE_BUILTINS
|
||||
#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)
|
||||
@@ -18,7 +18,13 @@
|
||||
// #############################################################################
|
||||
|
||||
|
||||
#if ATOMICS_NATIVE_BUILTINS
|
||||
// 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
|
||||
@@ -2110,7 +2116,7 @@ extension UnsafeMutablePointer where Pointee == _AtomicInt64Storage {
|
||||
}
|
||||
}
|
||||
|
||||
#if compiler(>=5.9) && _pointerBitWidth(_64)
|
||||
#if _pointerBitWidth(_64)
|
||||
@usableFromInline
|
||||
@frozen
|
||||
@_alignment(16)
|
||||
@@ -2438,14 +2444,18 @@ extension UnsafeMutablePointer where Pointee == _AtomicInt128Storage {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if compiler(>=5.9) && _pointerBitWidth(_64)
|
||||
#if _pointerBitWidth(_64)
|
||||
@usableFromInline internal typealias _AtomicIntStorage = _AtomicInt64Storage
|
||||
@usableFromInline internal typealias _AtomicDoubleWordStorage = _AtomicInt128Storage
|
||||
#elseif compiler(>=5.9) && _pointerBitWidth(_32)
|
||||
#elseif _pointerBitWidth(_32)
|
||||
@usableFromInline internal typealias _AtomicIntStorage = _AtomicInt32Storage
|
||||
@usableFromInline internal typealias _AtomicDoubleWordStorage = _AtomicInt64Storage
|
||||
#else
|
||||
#error("Unexpected pointer bit width")
|
||||
#endif
|
||||
|
||||
#endif // ATOMICS_NATIVE_BUILTINS
|
||||
#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)
|
||||
@@ -10,10 +10,17 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if ATOMICS_NATIVE_BUILTINS
|
||||
// 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 compiler(>=5.9) && _pointerBitWidth(_32)
|
||||
#if _pointerBitWidth(_32)
|
||||
@frozen
|
||||
@_alignment(8)
|
||||
public struct DoubleWord {
|
||||
@@ -29,7 +36,7 @@ public struct DoubleWord {
|
||||
self.second = second
|
||||
}
|
||||
}
|
||||
#elseif compiler(>=5.9) && _pointerBitWidth(_64)
|
||||
#elseif _pointerBitWidth(_64)
|
||||
@frozen
|
||||
@_alignment(16)
|
||||
public struct DoubleWord {
|
||||
@@ -63,10 +70,14 @@ extension DoubleWord {
|
||||
}
|
||||
}
|
||||
|
||||
#else // !ATOMICS_NATIVE_BUILTINS
|
||||
#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
|
||||
#endif // compiler(>=5.9)
|
||||
|
||||
extension DoubleWord {
|
||||
/// Initialize a new `DoubleWord` value given its high- and
|
||||
|
||||
Reference in new issue
Block a user