Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stdlib] Replace #elseif with #else for 64-bit platforms #14409

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions stdlib/private/SwiftPrivate/PRNG.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ public func rand64() -> UInt64 {
public func randInt() -> Int {
#if arch(i386) || arch(arm)
return Int(Int32(bitPattern: rand32()))
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
return Int(Int64(bitPattern: rand64()))
#else
fatalError("unimplemented")
return Int(Int64(bitPattern: rand64()))
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/core/Hashing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public // @testable
func _mixUInt(_ value: UInt) -> UInt {
#if arch(i386) || arch(arm)
return UInt(_mixUInt32(UInt32(value)))
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
#else
return UInt(_mixUInt64(UInt64(value)))
#endif
}
Expand All @@ -154,7 +154,7 @@ public // @testable
func _mixInt(_ value: Int) -> Int {
#if arch(i386) || arch(arm)
return Int(_mixInt32(Int32(value)))
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
#else
return Int(_mixInt64(Int64(value)))
#endif
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func _combineHashValues(_ firstValue: Int, _ secondValue: Int) -> Int {
// (0x1.9e3779b97f4a7c15f39cc0605cedc8341082276bf3a27251f86c6a11d0c18e95p0).
#if arch(i386) || arch(arm)
let magic = 0x9e3779b9 as UInt
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
#else
let magic = 0x9e3779b97f4a7c15 as UInt
#endif
var x = UInt(bitPattern: firstValue)
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/core/Runtime.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ internal func _stdlib_atomicCompareExchangeStrongInt(
#if arch(i386) || arch(arm)
let (oldValue, won) = Builtin.cmpxchg_seqcst_seqcst_Int32(
target._rawValue, expected.pointee._value, desired._value)
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
#else
let (oldValue, won) = Builtin.cmpxchg_seqcst_seqcst_Int64(
target._rawValue, expected.pointee._value, desired._value)
#endif
Expand All @@ -227,7 +227,7 @@ internal func _swift_stdlib_atomicStoreInt(
desired: Int) {
#if arch(i386) || arch(arm)
Builtin.atomicstore_seqcst_Int32(target._rawValue, desired._value)
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
#else
Builtin.atomicstore_seqcst_Int64(target._rawValue, desired._value)
#endif
}
Expand All @@ -239,7 +239,7 @@ public func _swift_stdlib_atomicLoadInt(
#if arch(i386) || arch(arm)
let value = Builtin.atomicload_seqcst_Int32(target._rawValue)
return Int(value)
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
#else
let value = Builtin.atomicload_seqcst_Int64(target._rawValue)
return Int(value)
#endif
Expand Down Expand Up @@ -269,7 +269,7 @@ public func _swift_stdlib_atomicFetch${operation}Int(
let value = _swift_stdlib_atomicFetch${operation}Int32(
object: rawTarget.assumingMemoryBound(to: Int32.self),
operand: Int32(operand))
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
#else
let value = _swift_stdlib_atomicFetch${operation}Int64(
object: rawTarget.assumingMemoryBound(to: Int64.self),
operand: Int64(operand))
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/SipHash.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ struct ${Self} {
let hash: UInt64 = finalizeAndReturnHash()
#if arch(i386) || arch(arm)
return Int(truncatingIfNeeded: hash)
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x)
#else
return Int(Int64(bitPattern: hash))
#endif
}
Expand Down