aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Common/BitUtils.cs
diff options
context:
space:
mode:
authorjduncanator <1518948+jduncanator@users.noreply.github.com>2019-01-11 11:11:46 +1100
committerAc_K <Acoustik666@gmail.com>2019-01-11 01:11:46 +0100
commit8406ec6272392a3f7f7672d85fdde333b6c70378 (patch)
treeb8d3f0a1692015c4bd56897cf7146877aa967da0 /Ryujinx.Common/BitUtils.cs
parent600799ba87fd59c3a6ef56e55a689a1ebdc410a6 (diff)
Refactor Ryujinx.Common and HLE Stub Logging (#537)
* Refactor Ryujinx.Common and HLE Stub Logging * Resolve review comments * Rename missed loop variable * Optimize PrintStub logging function * Pass the call-sites Thread ID through to the logger * Remove superfluous lock from ConsoleLog * Process logged data objects in the logger target Pass the data object all the way to the output logger targets, to allow them to "serialize" this in whatever appropriate format they're logging in. * Use existing StringBuilder to build the properties string * Add a ServiceNotImplemented Exception Useful for printing debug information about unimplemented service calls * Resolve Style Nits * Resolve Merge Issues * Fix typo and align declarations
Diffstat (limited to 'Ryujinx.Common/BitUtils.cs')
-rw-r--r--Ryujinx.Common/BitUtils.cs90
1 files changed, 45 insertions, 45 deletions
diff --git a/Ryujinx.Common/BitUtils.cs b/Ryujinx.Common/BitUtils.cs
index 5c858029..135b397d 100644
--- a/Ryujinx.Common/BitUtils.cs
+++ b/Ryujinx.Common/BitUtils.cs
@@ -2,103 +2,103 @@ namespace Ryujinx.Common
{
public static class BitUtils
{
- public static int AlignUp(int Value, int Size)
+ private static readonly byte[] ClzNibbleTbl = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+ public static int AlignUp(int value, int size)
{
- return (Value + (Size - 1)) & -Size;
+ return (value + (size - 1)) & -size;
}
- public static ulong AlignUp(ulong Value, int Size)
+ public static ulong AlignUp(ulong value, int size)
{
- return (ulong)AlignUp((long)Value, Size);
+ return (ulong)AlignUp((long)value, size);
}
- public static long AlignUp(long Value, int Size)
+ public static long AlignUp(long value, int size)
{
- return (Value + (Size - 1)) & -(long)Size;
+ return (value + (size - 1)) & -(long)size;
}
- public static int AlignDown(int Value, int Size)
+ public static int AlignDown(int value, int size)
{
- return Value & -Size;
+ return value & -size;
}
- public static ulong AlignDown(ulong Value, int Size)
+ public static ulong AlignDown(ulong value, int size)
{
- return (ulong)AlignDown((long)Value, Size);
+ return (ulong)AlignDown((long)value, size);
}
- public static long AlignDown(long Value, int Size)
+ public static long AlignDown(long value, int size)
{
- return Value & -(long)Size;
+ return value & -(long)size;
}
- public static ulong DivRoundUp(ulong Value, uint Dividend)
+ public static ulong DivRoundUp(ulong value, uint dividend)
{
- return (Value + Dividend - 1) / Dividend;
+ return (value + dividend - 1) / dividend;
}
- public static long DivRoundUp(long Value, int Dividend)
+ public static long DivRoundUp(long value, int dividend)
{
- return (Value + Dividend - 1) / Dividend;
+ return (value + dividend - 1) / dividend;
}
- public static bool IsPowerOfTwo32(int Value)
+ public static bool IsPowerOfTwo32(int value)
{
- return Value != 0 && (Value & (Value - 1)) == 0;
+ return value != 0 && (value & (value - 1)) == 0;
}
- public static bool IsPowerOfTwo64(long Value)
+ public static bool IsPowerOfTwo64(long value)
{
- return Value != 0 && (Value & (Value - 1)) == 0;
+ return value != 0 && (value & (value - 1)) == 0;
}
- public static int CountLeadingZeros32(int Value)
+ public static int CountLeadingZeros32(int value)
{
- return (int)CountLeadingZeros((ulong)Value, 32);
+ return (int)CountLeadingZeros((ulong)value, 32);
}
- public static int CountLeadingZeros64(long Value)
+ public static int CountLeadingZeros64(long value)
{
- return (int)CountLeadingZeros((ulong)Value, 64);
+ return (int)CountLeadingZeros((ulong)value, 64);
}
- private static readonly byte[] ClzNibbleTbl = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- private static ulong CountLeadingZeros(ulong Value, int Size) // Size is 8, 16, 32 or 64 (SIMD&FP or Base Inst.).
+ private static ulong CountLeadingZeros(ulong value, int size)
{
- if (Value == 0ul)
+ if (value == 0ul)
{
- return (ulong)Size;
+ return (ulong)size;
}
- int NibbleIdx = Size;
- int PreCount, Count = 0;
+ int nibbleIdx = size;
+ int preCount, count = 0;
do
{
- NibbleIdx -= 4;
- PreCount = ClzNibbleTbl[(Value >> NibbleIdx) & 0b1111];
- Count += PreCount;
+ nibbleIdx -= 4;
+ preCount = ClzNibbleTbl[(value >> nibbleIdx) & 0b1111];
+ count += preCount;
}
- while (PreCount == 4);
+ while (preCount == 4);
- return (ulong)Count;
+ return (ulong)count;
}
- public static long ReverseBits64(long Value)
+ public static long ReverseBits64(long value)
{
- return (long)ReverseBits64((ulong)Value);
+ return (long)ReverseBits64((ulong)value);
}
- private static ulong ReverseBits64(ulong Value)
+ private static ulong ReverseBits64(ulong value)
{
- Value = ((Value & 0xaaaaaaaaaaaaaaaa) >> 1 ) | ((Value & 0x5555555555555555) << 1 );
- Value = ((Value & 0xcccccccccccccccc) >> 2 ) | ((Value & 0x3333333333333333) << 2 );
- Value = ((Value & 0xf0f0f0f0f0f0f0f0) >> 4 ) | ((Value & 0x0f0f0f0f0f0f0f0f) << 4 );
- Value = ((Value & 0xff00ff00ff00ff00) >> 8 ) | ((Value & 0x00ff00ff00ff00ff) << 8 );
- Value = ((Value & 0xffff0000ffff0000) >> 16) | ((Value & 0x0000ffff0000ffff) << 16);
+ value = ((value & 0xaaaaaaaaaaaaaaaa) >> 1 ) | ((value & 0x5555555555555555) << 1 );
+ value = ((value & 0xcccccccccccccccc) >> 2 ) | ((value & 0x3333333333333333) << 2 );
+ value = ((value & 0xf0f0f0f0f0f0f0f0) >> 4 ) | ((value & 0x0f0f0f0f0f0f0f0f) << 4 );
+ value = ((value & 0xff00ff00ff00ff00) >> 8 ) | ((value & 0x00ff00ff00ff00ff) << 8 );
+ value = ((value & 0xffff0000ffff0000) >> 16) | ((value & 0x0000ffff0000ffff) << 16);
- return (Value >> 32) | (Value << 32);
+ return (value >> 32) | (value << 32);
}
}
} \ No newline at end of file