Last active
March 18, 2022 18:35
-
-
Save colemancda/032d600a1bdc86788f112df7c428a81d to your computer and use it in GitHub Desktop.
Foundation 5.6 patched for MIPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Darwin/Foundation-swiftoverlay/Data.swift b/Darwin/Foundation-swiftoverlay/Data.swift | |
index d1a4386d..31ba9847 100644 | |
--- a/Darwin/Foundation-swiftoverlay/Data.swift | |
+++ b/Darwin/Foundation-swiftoverlay/Data.swift | |
@@ -653,11 +653,11 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl | |
@usableFromInline | |
@frozen | |
internal struct InlineData { | |
-#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
@usableFromInline typealias Buffer = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, | |
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) //len //enum | |
@usableFromInline var bytes: Buffer | |
-#elseif arch(i386) || arch(arm) | |
+#elseif arch(i386) || arch(arm) || arch(mips) || arch(mipsel) | |
@usableFromInline typealias Buffer = (UInt8, UInt8, UInt8, UInt8, | |
UInt8, UInt8) //len //enum | |
@usableFromInline var bytes: Buffer | |
@@ -682,9 +682,9 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl | |
@inlinable // This is @inlinable as a trivial initializer. | |
init(count: Int = 0) { | |
assert(count <= MemoryLayout<Buffer>.size) | |
-#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
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)) | |
-#elseif arch(i386) || arch(arm) | |
+#elseif arch(i386) || arch(arm) || arch(mips) || arch(mipsel) | |
bytes = (UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0)) | |
#endif | |
length = UInt8(count) | |
@@ -863,9 +863,9 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl | |
} | |
} | |
-#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
@usableFromInline internal typealias HalfInt = Int32 | |
-#elseif arch(i386) || arch(arm) | |
+#elseif arch(i386) || arch(arm) || arch(mips) || arch(mipsel) | |
@usableFromInline internal typealias HalfInt = Int16 | |
#endif | |
diff --git a/Darwin/Foundation-swiftoverlay/Scanner.swift b/Darwin/Foundation-swiftoverlay/Scanner.swift | |
index 1a30a558..20be791c 100644 | |
--- a/Darwin/Foundation-swiftoverlay/Scanner.swift | |
+++ b/Darwin/Foundation-swiftoverlay/Scanner.swift | |
@@ -86,11 +86,11 @@ extension Scanner { | |
} | |
public func scanInt(representation: NumberRepresentation = .decimal) -> Int? { | |
-#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
if let value = scanInt64(representation: representation) { | |
return Int(value) | |
} | |
-#elseif arch(i386) || arch(arm) | |
+#elseif arch(i386) || arch(arm) || arch(mips) || arch(mipsel) | |
if let value = scanInt32(representation: representation) { | |
return Int(value) | |
} | |
diff --git a/Sources/Foundation/CGFloat.swift b/Sources/Foundation/CGFloat.swift | |
index 61276c83..38b4e8d6 100644 | |
--- a/Sources/Foundation/CGFloat.swift | |
+++ b/Sources/Foundation/CGFloat.swift | |
@@ -9,11 +9,11 @@ | |
@frozen | |
public struct CGFloat { | |
-#if arch(i386) || arch(arm) || arch(wasm32) | |
+#if arch(i386) || arch(arm) || arch(wasm32) || arch(mips) || arch(mipsel) | |
/// The native type used to store the CGFloat, which is Float on | |
/// 32-bit architectures and Double on 64-bit architectures. | |
public typealias NativeType = Float | |
-#elseif arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#elseif arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
/// The native type used to store the CGFloat, which is Float on | |
/// 32-bit architectures and Double on 64-bit architectures. | |
public typealias NativeType = Double | |
@@ -185,9 +185,9 @@ extension CGFloat : BinaryFloatingPoint { | |
@_transparent | |
public init(bitPattern: UInt) { | |
-#if arch(i386) || arch(arm) || arch(wasm32) | |
+#if arch(i386) || arch(arm) || arch(wasm32) || arch(mips) || arch(mipsel) | |
native = NativeType(bitPattern: UInt32(bitPattern)) | |
-#elseif arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#elseif arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
native = NativeType(bitPattern: UInt64(bitPattern)) | |
#else | |
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.") | |
diff --git a/Sources/Foundation/Data.swift b/Sources/Foundation/Data.swift | |
index a808240b..2b2a1b67 100644 | |
--- a/Sources/Foundation/Data.swift | |
+++ b/Sources/Foundation/Data.swift | |
@@ -668,11 +668,11 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl | |
@usableFromInline | |
@frozen | |
internal struct InlineData { | |
-#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
@usableFromInline typealias Buffer = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, | |
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) //len //enum | |
@usableFromInline var bytes: Buffer | |
-#elseif arch(i386) || arch(arm) || arch(wasm32) | |
+#elseif arch(i386) || arch(arm) || arch(wasm32) || arch(mips) || arch(mipsel) | |
@usableFromInline typealias Buffer = (UInt8, UInt8, UInt8, UInt8, | |
UInt8, UInt8) //len //enum | |
@usableFromInline var bytes: Buffer | |
@@ -699,9 +699,9 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl | |
@inlinable // This is @inlinable as a trivial initializer. | |
init(count: Int = 0) { | |
assert(count <= MemoryLayout<Buffer>.size) | |
-#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
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)) | |
-#elseif arch(i386) || arch(arm) || arch(wasm32) | |
+#elseif arch(i386) || arch(arm) || arch(wasm32) || arch(mips) || arch(mipsel) | |
bytes = (UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0)) | |
#else | |
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.") | |
@@ -882,9 +882,9 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl | |
} | |
} | |
-#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
@usableFromInline internal typealias HalfInt = Int32 | |
-#elseif arch(i386) || arch(arm) || arch(wasm32) | |
+#elseif arch(i386) || arch(arm) || arch(wasm32) || arch(mips) || arch(mipsel) | |
@usableFromInline internal typealias HalfInt = Int16 | |
#else | |
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.") | |
diff --git a/Sources/Foundation/NSNumber.swift b/Sources/Foundation/NSNumber.swift | |
index 38e89043..5968f549 100644 | |
--- a/Sources/Foundation/NSNumber.swift | |
+++ b/Sources/Foundation/NSNumber.swift | |
@@ -736,9 +736,9 @@ open class NSNumber : NSValue { | |
public convenience init(value: Int) { | |
var value = value | |
- #if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+ #if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
self.init(bytes: &value, numberType: kCFNumberSInt64Type) | |
- #elseif arch(i386) || arch(arm) || arch(wasm32) | |
+ #elseif arch(i386) || arch(arm) || arch(wasm32) || arch(mips) || arch(mipsel) | |
self.init(bytes: &value, numberType: kCFNumberSInt32Type) | |
#else | |
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.") | |
@@ -746,7 +746,7 @@ open class NSNumber : NSValue { | |
} | |
public convenience init(value: UInt) { | |
- #if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+ #if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
if value > UInt64(Int64.max) { | |
var value = CFSInt128Struct(high: 0, low: UInt64(value)) | |
self.init(bytes: &value, numberType: kCFNumberSInt128Type) | |
@@ -754,7 +754,7 @@ open class NSNumber : NSValue { | |
var value = Int64(value) | |
self.init(bytes: &value, numberType: kCFNumberSInt64Type) | |
} | |
- #elseif arch(i386) || arch(arm) || arch(wasm32) | |
+ #elseif arch(i386) || arch(arm) || arch(wasm32) || arch(mips) || arch(mipsel) | |
var value = Int64(value) | |
self.init(bytes: &value, numberType: kCFNumberSInt64Type) | |
#else | |
diff --git a/Sources/Foundation/NSRange.swift b/Sources/Foundation/NSRange.swift | |
index ee6eec84..b87efd79 100644 | |
--- a/Sources/Foundation/NSRange.swift | |
+++ b/Sources/Foundation/NSRange.swift | |
@@ -379,9 +379,9 @@ extension NSRange: NSSpecialValueCoding { | |
} | |
static func objCType() -> String { | |
-#if arch(i386) || arch(arm) || arch(wasm32) | |
+#if arch(i386) || arch(arm) || arch(wasm32) || arch(mips) || arch(mipsel) | |
return "{_NSRange=II}" | |
-#elseif arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+#elseif arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
return "{_NSRange=QQ}" | |
#else | |
#error("This architecture isn't known. Add it to the 32-bit or 64-bit line.") | |
diff --git a/Sources/Foundation/ScannerAPI.swift b/Sources/Foundation/ScannerAPI.swift | |
index d3fe75ed..1ff9c63f 100644 | |
--- a/Sources/Foundation/ScannerAPI.swift | |
+++ b/Sources/Foundation/ScannerAPI.swift | |
@@ -39,11 +39,11 @@ extension Scanner { | |
} | |
public func scanInt(representation: NumberRepresentation = .decimal) -> Int? { | |
- #if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+ #if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
if let value = scanInt64(representation: representation) { | |
return Int(value) | |
} | |
- #elseif arch(i386) || arch(arm) | |
+ #elseif arch(i386) || arch(arm) || arch(mips) || arch(mipsel) | |
if let value = scanInt32(representation: representation) { | |
return Int(value) | |
} | |
diff --git a/Tests/Foundation/Tests/TestNSNumber.swift b/Tests/Foundation/Tests/TestNSNumber.swift | |
index 7bcd453e..88cf98bb 100644 | |
--- a/Tests/Foundation/Tests/TestNSNumber.swift | |
+++ b/Tests/Foundation/Tests/TestNSNumber.swift | |
@@ -1227,12 +1227,12 @@ class TestNSNumber : XCTestCase { | |
XCTAssertEqual("Q" /* 0x51 */, objCType(NSNumber(value: UInt64(Int64.max) + 1))) | |
// Depends on architectures | |
- #if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) | |
+ #if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) || arch(mips64) || arch(mips64el) | |
XCTAssertEqual("q" /* 0x71 */, objCType(NSNumber(value: Int.max))) | |
// When value is lower equal to `Int.max`, it returns 'q' even if using `UInt` | |
XCTAssertEqual("q" /* 0x71 */, objCType(NSNumber(value: UInt(Int.max)))) | |
XCTAssertEqual("Q" /* 0x51 */, objCType(NSNumber(value: UInt(Int.max) + 1))) | |
- #elseif arch(i386) || arch(arm) | |
+ #elseif arch(i386) || arch(arm) || arch(mips) || arch(mipsel) | |
XCTAssertEqual("i" /* 0x71 */, objCType(NSNumber(value: Int.max))) | |
XCTAssertEqual("q" /* 0x71 */, objCType(NSNumber(value: UInt(Int.max)))) | |
XCTAssertEqual("q" /* 0x51 */, objCType(NSNumber(value: UInt(Int.max) + 1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment