From f2a41b7a1cad027cc1f1f8f687cda6ab42030eb9 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 22 Jun 2022 12:28:14 -0300 Subject: Rewrite kernel memory allocator (#3316) * Rewrite kernel memory allocator * Remove unused using * Adjust private static field naming * Change UlongBitSize to UInt64BitSize * Fix unused argument, change argument order to be inline with official code and disable random allocation --- Ryujinx.Common/Utilities/BitUtils.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Common/Utilities/BitUtils.cs') diff --git a/Ryujinx.Common/Utilities/BitUtils.cs b/Ryujinx.Common/Utilities/BitUtils.cs index b231886f..5c68dc9e 100644 --- a/Ryujinx.Common/Utilities/BitUtils.cs +++ b/Ryujinx.Common/Utilities/BitUtils.cs @@ -22,7 +22,17 @@ namespace Ryujinx.Common public static long AlignUp(long value, int size) { - return (value + (size - 1)) & -(long)size; + return AlignUp(value, (long)size); + } + + public static ulong AlignUp(ulong value, ulong size) + { + return (ulong)AlignUp((long)value, (long)size); + } + + public static long AlignUp(long value, long size) + { + return (value + (size - 1)) & -size; } public static uint AlignDown(uint value, int size) @@ -42,7 +52,17 @@ namespace Ryujinx.Common public static long AlignDown(long value, int size) { - return value & -(long)size; + return AlignDown(value, (long)size); + } + + public static ulong AlignDown(ulong value, ulong size) + { + return (ulong)AlignDown((long)value, (long)size); + } + + public static long AlignDown(long value, long size) + { + return value & -size; } public static int DivRoundUp(int value, int dividend) -- cgit v1.2.3