diff options
Diffstat (limited to 'Ryujinx.HLE/Utilities')
| -rw-r--r-- | Ryujinx.HLE/Utilities/UInt128.cs | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/Ryujinx.HLE/Utilities/UInt128.cs b/Ryujinx.HLE/Utilities/UInt128.cs index 8f5fc28f..22d87f6b 100644 --- a/Ryujinx.HLE/Utilities/UInt128.cs +++ b/Ryujinx.HLE/Utilities/UInt128.cs @@ -1,13 +1,15 @@ using System; using System.IO; using System.Linq; +using System.Runtime.InteropServices; namespace Ryujinx.HLE.Utilities { - public struct UInt128 + [StructLayout(LayoutKind.Sequential)] + public struct UInt128 : IEquatable<UInt128> { - public long High { get; private set; } - public long Low { get; private set; } + public readonly long Low; + public readonly long High; public bool IsNull => (Low | High) == 0; @@ -45,9 +47,29 @@ namespace Ryujinx.HLE.Utilities return High.ToString("x16") + Low.ToString("x16"); } - public bool IsZero() + public static bool operator ==(UInt128 x, UInt128 y) { - return (Low | High) == 0; + return x.Equals(y); + } + + public static bool operator !=(UInt128 x, UInt128 y) + { + return !x.Equals(y); + } + + public override bool Equals(object obj) + { + return obj is UInt128 uint128 && Equals(uint128); + } + + public bool Equals(UInt128 cmpObj) + { + return Low == cmpObj.Low && High == cmpObj.High; + } + + public override int GetHashCode() + { + return HashCode.Combine(Low, High); } } }
\ No newline at end of file |
