Skip to content

Commit b0d7c05

Browse files
committed
[Foundation] Fallback to presuming 32-bit platforms if we dont explicitly know that it is 64 bit; this allows for better portability
1 parent 5154886 commit b0d7c05

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

stdlib/public/Darwin/Foundation/Data.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,15 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
683683
@usableFromInline
684684
typealias Buffer = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8,
685685
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) //len //enum
686-
@usableFromInline
687-
var bytes: Buffer
688-
#elseif arch(i386) || arch(arm)
686+
#elseif arch(i386) || arch(arm) || arch(arm64_32)
689687
@usableFromInline
690688
typealias Buffer = (UInt8, UInt8, UInt8, UInt8,
691689
UInt8, UInt8) //len //enum
690+
#else
691+
#error ("Unsupported architecture: a definition of Buffer needs to be made with N = (MemoryLayout<(Int, Int)>.size - 2) UInt8 members to a tuple")
692+
#endif
692693
@usableFromInline
693694
var bytes: Buffer
694-
#endif
695695
@usableFromInline
696696
var length: UInt8
697697

@@ -720,9 +720,11 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
720720
assert(count <= MemoryLayout<Buffer>.size)
721721
#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le)
722722
bytes = (UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0))
723-
#elseif arch(i386) || arch(arm)
723+
#elseif arch(i386) || arch(arm) || arch(arm64_32)
724724
bytes = (UInt8(0), UInt8(0), UInt8(0), UInt8(0),
725725
UInt8(0), UInt8(0))
726+
#else
727+
#error ("Unsupported architecture: initialization for Buffer is required for this architecture")
726728
#endif
727729
length = UInt8(count)
728730
}
@@ -878,9 +880,11 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
878880
#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le)
879881
@usableFromInline
880882
internal typealias HalfInt = Int32
881-
#elseif arch(i386) || arch(arm)
883+
#elseif arch(i386) || arch(arm) || arch(arm64_32)
882884
@usableFromInline
883885
internal typealias HalfInt = Int16
886+
#else
887+
#error ("Unsupported architecture: a definition of half of the pointer sized Int needs to be defined for this architecture")
884888
#endif
885889

886890
@usableFromInline

0 commit comments

Comments
 (0)