misc: Replace references to IntPtr/UIntPtr with nint/nuint + code cleanups.

This commit is contained in:
Evan Husted 2024-10-26 08:46:41 -05:00
parent a09d314817
commit dfb4854d19
172 changed files with 902 additions and 914 deletions

View file

@ -273,7 +273,7 @@ namespace Ryujinx.Cpu.AppleHv
public static partial HvResult hv_vm_get_max_vcpu_count(out uint max_vcpu_count);
[LibraryImport(LibraryName, SetLastError = true)]
public static partial HvResult hv_vm_create(IntPtr config);
public static partial HvResult hv_vm_create(nint config);
[LibraryImport(LibraryName, SetLastError = true)]
public static partial HvResult hv_vm_destroy();
@ -288,7 +288,7 @@ namespace Ryujinx.Cpu.AppleHv
public static partial HvResult hv_vm_protect(ulong ipa, ulong size, HvMemoryFlags flags);
[LibraryImport(LibraryName, SetLastError = true)]
public unsafe static partial HvResult hv_vcpu_create(out ulong vcpu, ref HvVcpuExit* exit, IntPtr config);
public unsafe static partial HvResult hv_vcpu_create(out ulong vcpu, ref HvVcpuExit* exit, nint config);
[LibraryImport(LibraryName, SetLastError = true)]
public unsafe static partial HvResult hv_vcpu_destroy(ulong vcpu);

View file

@ -10,9 +10,9 @@ namespace Ryujinx.Cpu.AppleHv
class HvExecutionContextVcpu : IHvExecutionContext
{
private static readonly MemoryBlock _setSimdFpRegFuncMem;
private delegate HvResult SetSimdFpReg(ulong vcpu, HvSimdFPReg reg, in V128 value, IntPtr funcPtr);
private delegate HvResult SetSimdFpReg(ulong vcpu, HvSimdFPReg reg, in V128 value, nint funcPtr);
private static readonly SetSimdFpReg _setSimdFpReg;
private static readonly IntPtr _setSimdFpRegNativePtr;
private static readonly nint _setSimdFpRegNativePtr;
static HvExecutionContextVcpu()
{
@ -25,7 +25,7 @@ namespace Ryujinx.Cpu.AppleHv
_setSimdFpReg = Marshal.GetDelegateForFunctionPointer<SetSimdFpReg>(_setSimdFpRegFuncMem.Pointer);
if (NativeLibrary.TryLoad(HvApi.LibraryName, out IntPtr hvLibHandle))
if (NativeLibrary.TryLoad(HvApi.LibraryName, out nint hvLibHandle))
{
_setSimdFpRegNativePtr = NativeLibrary.GetExport(hvLibHandle, nameof(HvApi.hv_vcpu_set_simd_fp_reg));
}

View file

@ -32,7 +32,7 @@ namespace Ryujinx.Cpu.AppleHv
public int AddressSpaceBits { get; }
public IntPtr PageTablePointer => IntPtr.Zero;
public nint PageTablePointer => nint.Zero;
public MemoryManagerType Type => MemoryManagerType.SoftwarePageTable;
@ -244,7 +244,7 @@ namespace Ryujinx.Cpu.AppleHv
for (int i = 0; i < regions.Length; i++)
{
var guestRegion = guestRegions[i];
IntPtr pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size);
nint pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size);
regions[i] = new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size);
}

View file

@ -72,7 +72,7 @@ namespace Ryujinx.Cpu.AppleHv
// Create VCPU.
HvVcpuExit* exitInfo = null;
HvApi.hv_vcpu_create(out ulong vcpuHandle, ref exitInfo, IntPtr.Zero).ThrowOnError();
HvApi.hv_vcpu_create(out ulong vcpuHandle, ref exitInfo, nint.Zero).ThrowOnError();
// Enable FP and SIMD instructions.
HvApi.hv_vcpu_set_sys_reg(vcpuHandle, HvSysReg.CPACR_EL1, 0b11 << 20).ThrowOnError();

View file

@ -22,7 +22,7 @@ namespace Ryujinx.Cpu.AppleHv
{
if (++_addressSpaces == 1)
{
HvApi.hv_vm_create(IntPtr.Zero).ThrowOnError();
HvApi.hv_vm_create(nint.Zero).ThrowOnError();
_ipaAllocator = ipaAllocator = new HvIpaAllocator();
}
else