mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-23 01:21:21 -08:00
Added Generic Math to BitUtils (#3929)
* Generic Math Update Updated Several functions in Ryujinx.Common/Utilities/BitUtils to use generic math * Updated BitUtil calls * Removed Whitespace * Switched decrement * Fixed changed method calls. The method calls were originally changed on accident due to me relying too much on intellisense doing stuff for me * Update Ryujinx.Common/Utilities/BitUtils.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> Co-authored-by: gdkchan <gab.dark.100@gmail.com>
This commit is contained in:
parent
a4fdfb5f94
commit
c963b3c804
@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||
|
||||
if (size != 0)
|
||||
{
|
||||
ulong alignedOffset = BitUtils.AlignUp(Offset, align);
|
||||
ulong alignedOffset = BitUtils.AlignUp<ulong>(Offset, (ulong)align);
|
||||
|
||||
if (alignedOffset + size <= (ulong)BackingMemory.Length)
|
||||
{
|
||||
@ -55,7 +55,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||
|
||||
public static ulong GetTargetSize<T>(ulong currentSize, ulong count, int align) where T : unmanaged
|
||||
{
|
||||
return BitUtils.AlignUp(currentSize, align) + (ulong)Unsafe.SizeOf<T>() * count;
|
||||
return BitUtils.AlignUp<ulong>(currentSize, (ulong)align) + (ulong)Unsafe.SizeOf<T>() * count;
|
||||
}
|
||||
}
|
||||
}
|
@ -167,7 +167,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return ResultCode.WorkBufferTooSmall;
|
||||
}
|
||||
|
||||
_depopBuffer = workBufferAllocator.Allocate<float>((ulong)BitUtils.AlignUp(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment);
|
||||
_depopBuffer = workBufferAllocator.Allocate<float>(BitUtils.AlignUp<ulong>(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment);
|
||||
|
||||
if (_depopBuffer.IsEmpty)
|
||||
{
|
||||
@ -772,7 +772,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
size = WorkBufferAllocator.GetTargetSize<float>(size, Constants.TargetSampleCount * (Constants.VoiceChannelCountMax + parameter.MixBufferCount) * (parameter.SinkCount + parameter.SubMixBufferCount), 0x10);
|
||||
|
||||
// Depop buffer
|
||||
size = WorkBufferAllocator.GetTargetSize<float>(size, (ulong)BitUtils.AlignUp(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment);
|
||||
size = WorkBufferAllocator.GetTargetSize<float>(size, BitUtils.AlignUp<ulong>(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment);
|
||||
|
||||
// Voice
|
||||
size = WorkBufferAllocator.GetTargetSize<VoiceState>(size, parameter.VoiceCount, VoiceState.Alignment);
|
||||
@ -804,10 +804,10 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
ulong performanceMetricsPerFramesSize = PerformanceManager.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter, ref behaviourContext) * (parameter.PerformanceMetricFramesCount + 1) + 0xC;
|
||||
|
||||
size += BitUtils.AlignUp(performanceMetricsPerFramesSize, Constants.PerformanceMetricsPerFramesSizeAlignment);
|
||||
size += BitUtils.AlignUp<ulong>(performanceMetricsPerFramesSize, Constants.PerformanceMetricsPerFramesSizeAlignment);
|
||||
}
|
||||
|
||||
return BitUtils.AlignUp(size, Constants.WorkBufferAlignment);
|
||||
return BitUtils.AlignUp<ulong>(size, Constants.WorkBufferAlignment);
|
||||
}
|
||||
|
||||
public ResultCode QuerySystemEvent(out IWritableEvent systemEvent)
|
||||
|
@ -1,82 +1,26 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Ryujinx.Common
|
||||
{
|
||||
public static class BitUtils
|
||||
{
|
||||
public static uint AlignUp(uint value, int size)
|
||||
public static T AlignUp<T>(T value, T size)
|
||||
where T : IBinaryInteger<T>
|
||||
{
|
||||
return (uint)AlignUp((int)value, size);
|
||||
return (value + (size - T.One)) & -size;
|
||||
}
|
||||
|
||||
public static int AlignUp(int value, int size)
|
||||
{
|
||||
return (value + (size - 1)) & -size;
|
||||
}
|
||||
|
||||
public static ulong AlignUp(ulong value, int size)
|
||||
{
|
||||
return (ulong)AlignUp((long)value, size);
|
||||
}
|
||||
|
||||
public static long AlignUp(long value, int 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)
|
||||
{
|
||||
return (uint)AlignDown((int)value, size);
|
||||
}
|
||||
|
||||
public static int AlignDown(int value, int size)
|
||||
public static T AlignDown<T>(T value, T size)
|
||||
where T : IBinaryInteger<T>
|
||||
{
|
||||
return value & -size;
|
||||
}
|
||||
|
||||
public static ulong AlignDown(ulong value, int size)
|
||||
public static T DivRoundUp<T>(T value, T dividend)
|
||||
where T : IBinaryInteger<T>
|
||||
{
|
||||
return (ulong)AlignDown((long)value, size);
|
||||
}
|
||||
|
||||
public static long AlignDown(long value, int 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)
|
||||
{
|
||||
return (value + dividend - 1) / dividend;
|
||||
}
|
||||
|
||||
public static ulong DivRoundUp(ulong value, uint dividend)
|
||||
{
|
||||
return (value + dividend - 1) / dividend;
|
||||
}
|
||||
|
||||
public static long DivRoundUp(long value, int dividend)
|
||||
{
|
||||
return (value + dividend - 1) / dividend;
|
||||
return (value + (dividend - T.One)) / dividend;
|
||||
}
|
||||
|
||||
public static int Pow2RoundUp(int value)
|
||||
|
@ -100,7 +100,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
|
||||
_isLinear = (argument & 1) != 0;
|
||||
|
||||
_offset = 0;
|
||||
_size = (int)(BitUtils.AlignUp(state.LineLengthIn, 4) * state.LineCount);
|
||||
_size = (int)(BitUtils.AlignUp<uint>(state.LineLengthIn, 4) * state.LineCount);
|
||||
|
||||
int count = _size / 4;
|
||||
|
||||
|
@ -252,7 +252,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
RecordStorageAlignment(_cpStorageBuffers, index, gpuVa);
|
||||
|
||||
gpuVa = BitUtils.AlignDown(gpuVa, _context.Capabilities.StorageBufferOffsetAlignment);
|
||||
gpuVa = BitUtils.AlignDown<ulong>(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment);
|
||||
|
||||
ulong address = _channel.MemoryManager.Physical.BufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size);
|
||||
|
||||
@ -276,7 +276,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
RecordStorageAlignment(buffers, index, gpuVa);
|
||||
|
||||
gpuVa = BitUtils.AlignDown(gpuVa, _context.Capabilities.StorageBufferOffsetAlignment);
|
||||
gpuVa = BitUtils.AlignDown<ulong>(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment);
|
||||
|
||||
ulong address = _channel.MemoryManager.Physical.BufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size);
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
var range = _freeRanges[i];
|
||||
|
||||
ulong alignedOffset = BitUtils.AlignUp(range.Offset, (int)alignment);
|
||||
ulong alignedOffset = BitUtils.AlignUp<ulong>(range.Offset, alignment);
|
||||
ulong sizeDelta = alignedOffset - range.Offset;
|
||||
ulong usableSize = range.Size - sizeDelta;
|
||||
|
||||
@ -196,7 +196,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
ulong blockAlignedSize = BitUtils.AlignUp(size, _blockAlignment);
|
||||
ulong blockAlignedSize = BitUtils.AlignUp<ulong>(size, (ulong)_blockAlignment);
|
||||
|
||||
var memoryAllocateInfo = new MemoryAllocateInfo()
|
||||
{
|
||||
|
@ -81,8 +81,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
||||
attributeMask |= MemoryAttribute.DeviceMapped;
|
||||
}
|
||||
|
||||
ulong clientAddrTruncated = BitUtils.AlignDown(desc.ClientAddress, KPageTableBase.PageSize);
|
||||
ulong clientAddrRounded = BitUtils.AlignUp (desc.ClientAddress, KPageTableBase.PageSize);
|
||||
ulong clientAddrTruncated = BitUtils.AlignDown<ulong>(desc.ClientAddress, KPageTableBase.PageSize);
|
||||
ulong clientAddrRounded = BitUtils.AlignUp<ulong>(desc.ClientAddress, KPageTableBase.PageSize);
|
||||
|
||||
// Check if address is not aligned, in this case we need to perform 2 copies.
|
||||
if (clientAddrTruncated != clientAddrRounded)
|
||||
@ -113,9 +113,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
||||
ulong clientEndAddr = desc.ClientAddress + desc.Size;
|
||||
ulong serverEndAddr = desc.ServerAddress + desc.Size;
|
||||
|
||||
ulong clientEndAddrTruncated = BitUtils.AlignDown(clientEndAddr, KPageTableBase.PageSize);
|
||||
ulong clientEndAddrRounded = BitUtils.AlignUp (clientEndAddr, KPageTableBase.PageSize);
|
||||
ulong serverEndAddrTruncated = BitUtils.AlignDown(serverEndAddr, KPageTableBase.PageSize);
|
||||
ulong clientEndAddrTruncated = BitUtils.AlignDown<ulong>(clientEndAddr, (ulong)KPageTableBase.PageSize);
|
||||
ulong clientEndAddrRounded = BitUtils.AlignUp<ulong>(clientEndAddr, KPageTableBase.PageSize);
|
||||
ulong serverEndAddrTruncated = BitUtils.AlignDown<ulong>(serverEndAddr, (ulong)KPageTableBase.PageSize);
|
||||
|
||||
if (clientEndAddrTruncated < clientEndAddrRounded &&
|
||||
(clientAddrTruncated == clientAddrRounded || clientAddrTruncated < clientEndAddrTruncated))
|
||||
|
@ -1005,7 +1005,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
||||
recvListEndAddr = recvListBaseAddr + size;
|
||||
}
|
||||
|
||||
recvListBufferAddress = BitUtils.AlignUp(recvListBaseAddr + dstOffset, 0x10);
|
||||
recvListBufferAddress = BitUtils.AlignUp<ulong>(recvListBaseAddr + dstOffset, 0x10);
|
||||
|
||||
ulong endAddress = recvListBufferAddress + descriptor.BufferSize;
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
public KernelResult Map(ulong address, ulong size, KMemoryPermission perm)
|
||||
{
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp(size, KPageTableBase.PageSize))
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp<ulong>(size, (ulong)KPageTableBase.PageSize))
|
||||
{
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
public KernelResult MapToOwner(ulong address, ulong size, KMemoryPermission permission)
|
||||
{
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp(size, KPageTableBase.PageSize))
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp<ulong>(size, (ulong)KPageTableBase.PageSize))
|
||||
{
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
@ -102,7 +102,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
public KernelResult Unmap(ulong address, ulong size)
|
||||
{
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp(size, KPageTableBase.PageSize))
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp<ulong>(size, (ulong)KPageTableBase.PageSize))
|
||||
{
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
public KernelResult UnmapFromOwner(ulong address, ulong size)
|
||||
{
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp(size, KPageTableBase.PageSize))
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp<ulong>(size, KPageTableBase.PageSize))
|
||||
{
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
for (int depth = HighestDepthIndex; depth >= 0; depth--)
|
||||
{
|
||||
_bitStorages[depth] = storage;
|
||||
size = BitUtils.DivRoundUp(size, UInt64BitSize);
|
||||
size = BitUtils.DivRoundUp<ulong>(size, (ulong)UInt64BitSize);
|
||||
storage = storage.Slice((int)size);
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
for (int depth = GetRequiredDepth(regionSize) - 1; depth >= 0; depth--)
|
||||
{
|
||||
regionSize = BitUtils.DivRoundUp(regionSize, UInt64BitSize);
|
||||
regionSize = BitUtils.DivRoundUp<ulong>(regionSize, UInt64BitSize);
|
||||
overheadBits += (int)regionSize;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
int diff = 1 << (NextShift - Shift);
|
||||
|
||||
offset = BitUtils.AlignDown(offset, diff);
|
||||
offset = BitUtils.AlignDown(offset, (ulong)diff);
|
||||
|
||||
if (_bitmap.ClearRange(offset, diff))
|
||||
{
|
||||
|
@ -203,8 +203,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
heapRegion.Size = 0x180000000;
|
||||
stackRegion.Size = 0x80000000;
|
||||
tlsIoRegion.Size = 0x1000000000;
|
||||
CodeRegionStart = BitUtils.AlignDown(address, 0x200000);
|
||||
codeRegionSize = BitUtils.AlignUp(endAddr, 0x200000) - CodeRegionStart;
|
||||
CodeRegionStart = BitUtils.AlignDown<ulong>(address, 0x200000);
|
||||
codeRegionSize = BitUtils.AlignUp<ulong>(endAddr, 0x200000) - CodeRegionStart;
|
||||
stackAndTlsIoStart = 0;
|
||||
stackAndTlsIoEnd = 0;
|
||||
baseAddress = 0x8000000;
|
||||
@ -1584,8 +1584,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
return KernelResult.OutOfResource;
|
||||
}
|
||||
|
||||
ulong srcMapAddress = BitUtils.AlignUp(src, PageSize);
|
||||
ulong srcMapEndAddr = BitUtils.AlignDown(src + size, PageSize);
|
||||
ulong srcMapAddress = BitUtils.AlignUp<ulong>(src, PageSize);
|
||||
ulong srcMapEndAddr = BitUtils.AlignDown<ulong>(src + size, PageSize);
|
||||
ulong srcMapSize = srcMapEndAddr - srcMapAddress;
|
||||
|
||||
result = MapPagesFromClientProcess(size, src, permission, state, srcPageTable, send, out ulong va);
|
||||
@ -1659,10 +1659,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
attributeMask |= MemoryAttribute.DeviceMapped;
|
||||
}
|
||||
|
||||
ulong addressRounded = BitUtils.AlignUp(address, PageSize);
|
||||
ulong addressTruncated = BitUtils.AlignDown(address, PageSize);
|
||||
ulong endAddrRounded = BitUtils.AlignUp(endAddr, PageSize);
|
||||
ulong endAddrTruncated = BitUtils.AlignDown(endAddr, PageSize);
|
||||
ulong addressRounded = BitUtils.AlignUp<ulong>(address, PageSize);
|
||||
ulong addressTruncated = BitUtils.AlignDown<ulong>(address, PageSize);
|
||||
ulong endAddrRounded = BitUtils.AlignUp<ulong>(endAddr, PageSize);
|
||||
ulong endAddrTruncated = BitUtils.AlignDown<ulong>(endAddr, PageSize);
|
||||
|
||||
if (!_slabManager.CanAllocate(MaxBlocksNeededForInsertion))
|
||||
{
|
||||
@ -1769,10 +1769,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
ulong endAddr = address + size;
|
||||
|
||||
ulong addressTruncated = BitUtils.AlignDown(address, PageSize);
|
||||
ulong addressRounded = BitUtils.AlignUp(address, PageSize);
|
||||
ulong endAddrTruncated = BitUtils.AlignDown(endAddr, PageSize);
|
||||
ulong endAddrRounded = BitUtils.AlignUp(endAddr, PageSize);
|
||||
ulong addressTruncated = BitUtils.AlignDown<ulong>(address, PageSize);
|
||||
ulong addressRounded = BitUtils.AlignUp<ulong>(address, PageSize);
|
||||
ulong endAddrTruncated = BitUtils.AlignDown<ulong>(endAddr, PageSize);
|
||||
ulong endAddrRounded = BitUtils.AlignUp<ulong>(endAddr, PageSize);
|
||||
|
||||
ulong neededSize = endAddrRounded - addressTruncated;
|
||||
|
||||
@ -1983,10 +1983,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
return KernelResult.OutOfResource;
|
||||
}
|
||||
|
||||
ulong addressTruncated = BitUtils.AlignDown(address, PageSize);
|
||||
ulong addressRounded = BitUtils.AlignUp(address, PageSize);
|
||||
ulong endAddrTruncated = BitUtils.AlignDown(endAddr, PageSize);
|
||||
ulong endAddrRounded = BitUtils.AlignUp(endAddr, PageSize);
|
||||
ulong addressTruncated = BitUtils.AlignDown<ulong>(address, PageSize);
|
||||
ulong addressRounded = BitUtils.AlignUp<ulong>(address, PageSize);
|
||||
ulong endAddrTruncated = BitUtils.AlignDown<ulong>(endAddr, PageSize);
|
||||
ulong endAddrRounded = BitUtils.AlignUp<ulong>(endAddr, PageSize);
|
||||
|
||||
ulong pagesCount = (endAddrRounded - addressTruncated) / PageSize;
|
||||
|
||||
@ -2010,10 +2010,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
ulong endAddr = address + size;
|
||||
|
||||
ulong addressRounded = BitUtils.AlignUp(address, PageSize);
|
||||
ulong addressTruncated = BitUtils.AlignDown(address, PageSize);
|
||||
ulong endAddrRounded = BitUtils.AlignUp(endAddr, PageSize);
|
||||
ulong endAddrTruncated = BitUtils.AlignDown(endAddr, PageSize);
|
||||
ulong addressRounded = BitUtils.AlignUp<ulong>(address, PageSize);
|
||||
ulong addressTruncated = BitUtils.AlignDown<ulong>(address, PageSize);
|
||||
ulong endAddrRounded = BitUtils.AlignUp<ulong>(endAddr, PageSize);
|
||||
ulong endAddrTruncated = BitUtils.AlignDown<ulong>(endAddr, PageSize);
|
||||
|
||||
ulong pagesCount = addressRounded < endAddrTruncated ? (endAddrTruncated - addressRounded) / PageSize : 0;
|
||||
|
||||
@ -2540,7 +2540,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
for (int attempt = 0; attempt < 8; attempt++)
|
||||
{
|
||||
ulong aslrAddress = BitUtils.AlignDown(regionStart + GetRandomValue(0, aslrMaxOffset) * (ulong)alignment, alignment);
|
||||
ulong aslrAddress = BitUtils.AlignDown(regionStart + GetRandomValue(0, aslrMaxOffset) * (ulong)alignment, (ulong)alignment);
|
||||
ulong aslrEndAddr = aslrAddress + totalNeededSize;
|
||||
|
||||
KMemoryInfo info = _blockManager.FindBlock(aslrAddress).GetInfo();
|
||||
@ -2618,7 +2618,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
currBaseAddr += reservedSize;
|
||||
|
||||
ulong address = BitUtils.AlignDown(currBaseAddr, alignment) + reservedStart;
|
||||
ulong address = BitUtils.AlignDown<ulong>(currBaseAddr, (ulong)alignment) + reservedStart;
|
||||
|
||||
if (currBaseAddr > address)
|
||||
{
|
||||
@ -2834,7 +2834,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
lock (_blockManager)
|
||||
{
|
||||
return BitUtils.DivRoundUp(GetMmUsedSize(), PageSize);
|
||||
return BitUtils.DivRoundUp<ulong>(GetMmUsedSize(), PageSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
KProcess process,
|
||||
KMemoryPermission permission)
|
||||
{
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp(size, KPageTableBase.PageSize))
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp<ulong>(size, KPageTableBase.PageSize))
|
||||
{
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
public KernelResult UnmapFromProcess(KPageTableBase memoryManager, ulong address, ulong size, KProcess process)
|
||||
{
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp(size, KPageTableBase.PageSize))
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp<ulong>(size, KPageTableBase.PageSize))
|
||||
{
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
KProcess process,
|
||||
KMemoryPermission permission)
|
||||
{
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp(size, KPageTableBase.PageSize))
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp<ulong>(size, KPageTableBase.PageSize))
|
||||
{
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
@ -95,7 +95,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
ulong size,
|
||||
KProcess process)
|
||||
{
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp(size, KPageTableBase.PageSize))
|
||||
if (_pageList.GetPagesCount() != BitUtils.DivRoundUp<ulong>(size, (ulong)KPageTableBase.PageSize))
|
||||
{
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
public KernelResult FreeThreadLocalStorage(ulong tlsSlotAddr)
|
||||
{
|
||||
ulong tlsPageAddr = BitUtils.AlignDown(tlsSlotAddr, KPageTableBase.PageSize);
|
||||
ulong tlsPageAddr = BitUtils.AlignDown<ulong>(tlsSlotAddr, KPageTableBase.PageSize);
|
||||
|
||||
KernelContext.CriticalSection.Enter();
|
||||
|
||||
@ -554,7 +554,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
throw new InvalidOperationException("Trying to start a process with a invalid state!");
|
||||
}
|
||||
|
||||
ulong stackSizeRounded = BitUtils.AlignUp(stackSize, KPageTableBase.PageSize);
|
||||
ulong stackSizeRounded = BitUtils.AlignUp<ulong>(stackSize, KPageTableBase.PageSize);
|
||||
|
||||
ulong neededSize = stackSizeRounded + _imageSize;
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS
|
||||
endOffset = kip.BssOffset + kip.BssSize;
|
||||
}
|
||||
|
||||
uint codeSize = BitUtils.AlignUp(kip.TextOffset + endOffset, KPageTableBase.PageSize);
|
||||
uint codeSize = BitUtils.AlignUp<uint>(kip.TextOffset + endOffset, KPageTableBase.PageSize);
|
||||
|
||||
int codePagesCount = (int)(codeSize / KPageTableBase.PageSize);
|
||||
|
||||
@ -195,7 +195,7 @@ namespace Ryujinx.HLE.HOS
|
||||
nsoSize = dataEnd;
|
||||
}
|
||||
|
||||
nsoSize = BitUtils.AlignUp(nsoSize, KPageTableBase.PageSize);
|
||||
nsoSize = BitUtils.AlignUp<uint>(nsoSize, KPageTableBase.PageSize);
|
||||
|
||||
nsoBase[index] = codeStart + (ulong)codeSize;
|
||||
|
||||
@ -349,7 +349,7 @@ namespace Ryujinx.HLE.HOS
|
||||
return KernelResult.Success;
|
||||
}
|
||||
|
||||
size = BitUtils.AlignUp(size, KPageTableBase.PageSize);
|
||||
size = BitUtils.AlignUp<ulong>(size, KPageTableBase.PageSize);
|
||||
|
||||
return process.MemoryManager.SetProcessMemoryPermission(address, size, permission);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
||||
|
||||
ulong bssStart = dataStart + (ulong)relocatableObject.Data.Length;
|
||||
|
||||
ulong bssEnd = BitUtils.AlignUp(bssStart + (ulong)relocatableObject.BssSize, KPageTableBase.PageSize);
|
||||
ulong bssEnd = BitUtils.AlignUp<ulong>(bssStart + relocatableObject.BssSize, KPageTableBase.PageSize);
|
||||
|
||||
process.CpuMemory.Write(textStart, relocatableObject.Text);
|
||||
process.CpuMemory.Write(roStart, relocatableObject.Ro);
|
||||
|
@ -36,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
{
|
||||
uint headerSize = (uint)Unsafe.SizeOf<ParcelHeader>();
|
||||
|
||||
_rawData = new byte[BitUtils.AlignUp(headerSize + payloadSize + objectsSize, 4)];
|
||||
_rawData = new byte[BitUtils.AlignUp<uint>(headerSize + payloadSize + objectsSize, 4)];
|
||||
|
||||
Header.PayloadSize = payloadSize;
|
||||
Header.ObjectsSize = objectsSize;
|
||||
|
Loading…
Reference in New Issue
Block a user