misc: Replace references to IntPtr/UIntPtr with nint/nuint + code cleanups.
This commit is contained in:
@@ -11,17 +11,17 @@ namespace Ryujinx.Common.Memory
|
||||
/// <typeparam name="T">Array element type</typeparam>
|
||||
public unsafe struct ArrayPtr<T> : IEquatable<ArrayPtr<T>>, IArray<T> where T : unmanaged
|
||||
{
|
||||
private IntPtr _ptr;
|
||||
private nint _ptr;
|
||||
|
||||
/// <summary>
|
||||
/// Null pointer.
|
||||
/// </summary>
|
||||
public static ArrayPtr<T> Null => new() { _ptr = IntPtr.Zero };
|
||||
public static ArrayPtr<T> Null => new() { _ptr = nint.Zero };
|
||||
|
||||
/// <summary>
|
||||
/// True if the pointer is null, false otherwise.
|
||||
/// </summary>
|
||||
public readonly bool IsNull => _ptr == IntPtr.Zero;
|
||||
public readonly bool IsNull => _ptr == nint.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Number of elements on the array.
|
||||
@@ -50,7 +50,7 @@ namespace Ryujinx.Common.Memory
|
||||
/// <param name="length">Number of elements on the array</param>
|
||||
public ArrayPtr(ref T value, int length)
|
||||
{
|
||||
_ptr = (IntPtr)Unsafe.AsPointer(ref value);
|
||||
_ptr = (nint)Unsafe.AsPointer(ref value);
|
||||
Length = length;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Ryujinx.Common.Memory
|
||||
/// <param name="length">Number of elements on the array</param>
|
||||
public ArrayPtr(T* ptr, int length)
|
||||
{
|
||||
_ptr = (IntPtr)ptr;
|
||||
_ptr = (nint)ptr;
|
||||
Length = length;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Ryujinx.Common.Memory
|
||||
/// </summary>
|
||||
/// <param name="ptr">Array base pointer</param>
|
||||
/// <param name="length">Number of elements on the array</param>
|
||||
public ArrayPtr(IntPtr ptr, int length)
|
||||
public ArrayPtr(nint ptr, int length)
|
||||
{
|
||||
_ptr = ptr;
|
||||
Length = length;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||
public readonly static int PartialUnmapsCountOffset;
|
||||
public readonly static int LocalCountsOffset;
|
||||
|
||||
public readonly static IntPtr GlobalState;
|
||||
public readonly static nint GlobalState;
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[LibraryImport("kernel32.dll")]
|
||||
@@ -29,17 +29,17 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||
private static partial IntPtr OpenThread(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwThreadId);
|
||||
private static partial nint OpenThread(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwThreadId);
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool CloseHandle(IntPtr hObject);
|
||||
private static partial bool CloseHandle(nint hObject);
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool GetExitCodeThread(IntPtr hThread, out uint lpExitCode);
|
||||
private static partial bool GetExitCodeThread(nint hThread, out uint lpExitCode);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a global static PartialUnmapState and populates the field offsets.
|
||||
@@ -137,9 +137,9 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||
|
||||
if (id != 0)
|
||||
{
|
||||
IntPtr handle = OpenThread(ThreadQueryInformation, false, (uint)id);
|
||||
nint handle = OpenThread(ThreadQueryInformation, false, (uint)id);
|
||||
|
||||
if (handle == IntPtr.Zero)
|
||||
if (handle == nint.Zero)
|
||||
{
|
||||
Interlocked.CompareExchange(ref ids[i], 0, id);
|
||||
}
|
||||
|
||||
@@ -10,17 +10,17 @@ namespace Ryujinx.Common.Memory
|
||||
/// <typeparam name="T">Type of the unmanaged resource</typeparam>
|
||||
public unsafe struct Ptr<T> : IEquatable<Ptr<T>> where T : unmanaged
|
||||
{
|
||||
private IntPtr _ptr;
|
||||
private nint _ptr;
|
||||
|
||||
/// <summary>
|
||||
/// Null pointer.
|
||||
/// </summary>
|
||||
public static Ptr<T> Null => new() { _ptr = IntPtr.Zero };
|
||||
public static Ptr<T> Null => new() { _ptr = nint.Zero };
|
||||
|
||||
/// <summary>
|
||||
/// True if the pointer is null, false otherwise.
|
||||
/// </summary>
|
||||
public readonly bool IsNull => _ptr == IntPtr.Zero;
|
||||
public readonly bool IsNull => _ptr == nint.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the value.
|
||||
@@ -37,7 +37,7 @@ namespace Ryujinx.Common.Memory
|
||||
/// <param name="value">Reference to the unmanaged resource</param>
|
||||
public Ptr(ref T value)
|
||||
{
|
||||
_ptr = (IntPtr)Unsafe.AsPointer(ref value);
|
||||
_ptr = (nint)Unsafe.AsPointer(ref value);
|
||||
}
|
||||
|
||||
public readonly override bool Equals(object obj)
|
||||
|
||||
Reference in New Issue
Block a user