Skip to content

Commit 3eb8c79

Browse files
author
Gary Liu
committed
Fix _length access on CF_CONST_STRING for s390x
1 parent 59bacf9 commit 3eb8c79

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Foundation/NSCFString.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,20 @@ internal final class _NSCFConstantString : _NSCFString {
6262
let ptr = unsafeAddress(of: self) + sizeof(OpaquePointer.self) + sizeof(Int32.self) + sizeof(Int32.self) + sizeof(_CFInfo.self)
6363
return UnsafePointer<UnsafePointer<UInt8>>(ptr).pointee
6464
}
65+
66+
#if arch(s390x)
67+
internal var _length : UInt64 {
68+
let offset = sizeof(OpaquePointer.self) + sizeof(Int32.self) + sizeof(Int32.self) + sizeof(_CFInfo.self) + sizeof(UnsafePointer<UInt8>.self)
69+
let ptr = unsafeAddress(of: self) + offset
70+
return UnsafePointer<UInt64>(ptr).pointee
71+
}
72+
#else
6573
internal var _length : UInt32 {
6674
let offset = sizeof(OpaquePointer.self) + sizeof(Int32.self) + sizeof(Int32.self) + sizeof(_CFInfo.self) + sizeof(UnsafePointer<UInt8>.self)
6775
let ptr = unsafeAddress(of: self) + offset
6876
return UnsafePointer<UInt32>(ptr).pointee
6977
}
78+
#endif
7079

7180
required init(characters: UnsafePointer<unichar>, length: Int) {
7281
fatalError()

0 commit comments

Comments
 (0)