From fef93a453ac6a2032155a80feaf77d8f5db9cc5c Mon Sep 17 00:00:00 2001 From: GreemDev Date: Tue, 27 Jan 2026 17:41:46 -0600 Subject: [PATCH] [ci skip] replace all usages of IntPtr with nint --- src/ARMeilleure/Common/EntryTable.cs | 2 +- .../AppleHardwareDeviceDriver.cs | 20 +++++------ .../AppleHardwareDeviceSession.cs | 34 +++++++++---------- .../Native/SoundIoOutStreamContext.cs | 2 +- src/Ryujinx.Cpu/AddressTable.cs | 32 ++++++++--------- .../Image/TextureGroup.cs | 2 +- .../MoltenVK/MVKInitialization.cs | 2 +- .../VulkanInitialization.cs | 4 +-- .../Sockets/Bsd/Impl/ManagedSocket.cs | 2 +- .../WindowsShared/PlaceholderManager.cs | 2 +- src/Ryujinx.Tests/Memory/PartialUnmaps.cs | 2 +- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/ARMeilleure/Common/EntryTable.cs b/src/ARMeilleure/Common/EntryTable.cs index 7b8c1e134..1c154570a 100644 --- a/src/ARMeilleure/Common/EntryTable.cs +++ b/src/ARMeilleure/Common/EntryTable.cs @@ -168,7 +168,7 @@ namespace ARMeilleure.Common { _allocated.Dispose(); - foreach (IntPtr page in _pages.Values) + foreach (nint page in _pages.Values) { NativeAllocator.Instance.Free((void*)page); } diff --git a/src/Ryujinx.Audio.Backends.Apple/AppleHardwareDeviceDriver.cs b/src/Ryujinx.Audio.Backends.Apple/AppleHardwareDeviceDriver.cs index 80e55b9e5..f20da5557 100644 --- a/src/Ryujinx.Audio.Backends.Apple/AppleHardwareDeviceDriver.cs +++ b/src/Ryujinx.Audio.Backends.Apple/AppleHardwareDeviceDriver.cs @@ -44,12 +44,12 @@ namespace Ryujinx.Audio.Backends.Apple int result = AudioQueueNewOutput( ref format, - IntPtr.Zero, - IntPtr.Zero, - IntPtr.Zero, - IntPtr.Zero, + nint.Zero, + nint.Zero, + nint.Zero, + nint.Zero, 0, - out IntPtr testQueue); + out nint testQueue); if (result == 0) { @@ -95,12 +95,12 @@ namespace Ryujinx.Audio.Backends.Apple GetAudioFormat(SampleFormat.PcmInt16, Constants.TargetSampleRate, 2); int result = AudioQueueNewOutput( ref format, - IntPtr.Zero, - IntPtr.Zero, - IntPtr.Zero, - IntPtr.Zero, + nint.Zero, + nint.Zero, + nint.Zero, + nint.Zero, 0, - out IntPtr testQueue); + out nint testQueue); if (result == 0) { diff --git a/src/Ryujinx.Audio.Backends.Apple/AppleHardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.Apple/AppleHardwareDeviceSession.cs index c9443dcd3..05f9e2a3f 100644 --- a/src/Ryujinx.Audio.Backends.Apple/AppleHardwareDeviceSession.cs +++ b/src/Ryujinx.Audio.Backends.Apple/AppleHardwareDeviceSession.cs @@ -27,8 +27,8 @@ namespace Ryujinx.Audio.Backends.Apple private readonly AudioQueueOutputCallback _callbackDelegate; private readonly GCHandle _gcHandle; - private IntPtr _audioQueue; - private readonly IntPtr[] _audioQueueBuffers = new IntPtr[NumBuffers]; + private nint _audioQueue; + private readonly nint[] _audioQueueBuffers = new nint[NumBuffers]; private readonly int[] _bufferBytesFilled = new int[NumBuffers]; private readonly int _bytesPerFrame; @@ -41,9 +41,9 @@ namespace Ryujinx.Audio.Backends.Apple [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void AudioQueueOutputCallback( - IntPtr userData, - IntPtr audioQueue, - IntPtr buffer); + nint userData, + nint audioQueue, + nint buffer); public AppleHardwareDeviceSession( AppleHardwareDeviceDriver driver, @@ -72,15 +72,15 @@ namespace Ryujinx.Audio.Backends.Apple RequestedSampleRate, RequestedChannelCount); - IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(_callbackDelegate); - IntPtr userData = GCHandle.ToIntPtr(_gcHandle); + nint callbackPtr = Marshal.GetFunctionPointerForDelegate(_callbackDelegate); + nint userData = GCHandle.ToIntPtr(_gcHandle); int result = AudioQueueNewOutput( ref format, callbackPtr, userData, - IntPtr.Zero, - IntPtr.Zero, + nint.Zero, + nint.Zero, 0, out _audioQueue); @@ -102,7 +102,7 @@ namespace Ryujinx.Audio.Backends.Apple } } - private unsafe void PrimeBuffer(IntPtr bufferPtr, int bufferIndex) + private unsafe void PrimeBuffer(nint bufferPtr, int bufferIndex) { AudioQueueBuffer* buffer = (AudioQueueBuffer*)bufferPtr; @@ -126,12 +126,12 @@ namespace Ryujinx.Audio.Backends.Apple buffer->AudioDataByteSize = (uint)capacityBytes; _bufferBytesFilled[bufferIndex] = bytesToRead; - AudioQueueEnqueueBuffer(_audioQueue, bufferPtr, 0, IntPtr.Zero); + AudioQueueEnqueueBuffer(_audioQueue, bufferPtr, 0, nint.Zero); } - private void OutputCallback(IntPtr userData, IntPtr audioQueue, IntPtr bufferPtr) + private void OutputCallback(nint userData, nint audioQueue, nint bufferPtr) { - if (!_started || bufferPtr == IntPtr.Zero) + if (!_started || bufferPtr == nint.Zero) return; int bufferIndex = Array.IndexOf(_audioQueueBuffers, bufferPtr); @@ -176,7 +176,7 @@ namespace Ryujinx.Audio.Backends.Apple } } - private unsafe void ApplyVolume(IntPtr dataPtr, int byteSize) + private unsafe void ApplyVolume(nint dataPtr, int byteSize) { float volume = Math.Clamp(_volume * _driver.Volume, 0f, 1f); if (volume >= 0.999f) @@ -226,7 +226,7 @@ namespace Ryujinx.Audio.Backends.Apple return; _started = true; - AudioQueueStart(_audioQueue, IntPtr.Zero); + AudioQueueStart(_audioQueue, nint.Zero); } } @@ -265,11 +265,11 @@ namespace Ryujinx.Audio.Backends.Apple { Stop(); - if (_audioQueue != IntPtr.Zero) + if (_audioQueue != nint.Zero) { AudioQueueStop(_audioQueue, true); AudioQueueDispose(_audioQueue, true); - _audioQueue = IntPtr.Zero; + _audioQueue = nint.Zero; } if (_gcHandle.IsAllocated) diff --git a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs index 072e49d8c..56bd65e6d 100644 --- a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs +++ b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs @@ -130,7 +130,7 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native unsafe { int* frameCountPtr = &nativeFrameCount; - IntPtr* arenasPtr = &arenas; + nint* arenasPtr = &arenas; CheckError(soundio_outstream_begin_write(_context, (nint)arenasPtr, (nint)frameCountPtr)); frameCount = *frameCountPtr; diff --git a/src/Ryujinx.Cpu/AddressTable.cs b/src/Ryujinx.Cpu/AddressTable.cs index 91a65e899..19e405491 100644 --- a/src/Ryujinx.Cpu/AddressTable.cs +++ b/src/Ryujinx.Cpu/AddressTable.cs @@ -30,9 +30,9 @@ namespace ARMeilleure.Common /// /// Base address for the page. /// - public readonly IntPtr Address; + public readonly nint Address; - public AddressTablePage(bool isSparse, IntPtr address) + public AddressTablePage(bool isSparse, nint address) { IsSparse = isSparse; Address = address; @@ -47,20 +47,20 @@ namespace ARMeilleure.Common public readonly SparseMemoryBlock Block; private readonly TrackingEventDelegate _trackingEvent; - public TableSparseBlock(ulong size, Action ensureMapped, PageInitDelegate pageInit) + public TableSparseBlock(ulong size, Action ensureMapped, PageInitDelegate pageInit) { SparseMemoryBlock block = new(size, pageInit, null); _trackingEvent = (address, size, write) => { ulong pointer = (ulong)block.Block.Pointer + address; - ensureMapped((IntPtr)pointer); + ensureMapped((nint)pointer); return pointer; }; bool added = NativeSignalHandler.AddTrackedRegion( (nuint)block.Block.Pointer, - (nuint)(block.Block.Pointer + (IntPtr)block.Block.Size), + (nuint)(block.Block.Pointer + (nint)block.Block.Size), Marshal.GetFunctionPointerForDelegate(_trackingEvent)); if (!added) @@ -116,7 +116,7 @@ namespace ARMeilleure.Common } /// - public IntPtr Base + public nint Base { get { @@ -124,7 +124,7 @@ namespace ARMeilleure.Common lock (_pages) { - return (IntPtr)GetRootPage(); + return (nint)GetRootPage(); } } } @@ -240,7 +240,7 @@ namespace ARMeilleure.Common long index = Levels[^1].GetValue(address); - EnsureMapped((IntPtr)(page + index)); + EnsureMapped((nint)(page + index)); return ref page[index]; } @@ -284,7 +284,7 @@ namespace ARMeilleure.Common /// Ensure the given pointer is mapped in any overlapping sparse reservations. /// /// Pointer to be mapped - private void EnsureMapped(IntPtr ptr) + private void EnsureMapped(nint ptr) { if (Sparse) { @@ -299,7 +299,7 @@ namespace ARMeilleure.Common { SparseMemoryBlock sparse = reserved.Block; - if (ptr >= sparse.Block.Pointer && ptr < sparse.Block.Pointer + (IntPtr)sparse.Block.Size) + if (ptr >= sparse.Block.Pointer && ptr < sparse.Block.Pointer + (nint)sparse.Block.Size) { sparse.EnsureMapped((ulong)(ptr - sparse.Block.Pointer)); @@ -319,15 +319,15 @@ namespace ARMeilleure.Common /// /// Level to get the fill value for /// The fill value - private IntPtr GetFillValue(int level) + private nint GetFillValue(int level) { if (_fillBottomLevel != null && level == Levels.Length - 2) { - return (IntPtr)_fillBottomLevelPtr; + return (nint)_fillBottomLevelPtr; } else { - return IntPtr.Zero; + return nint.Zero; } } @@ -379,7 +379,7 @@ namespace ARMeilleure.Common /// Fill value /// if leaf; otherwise /// Allocated block - private IntPtr Allocate(int length, T fill, bool leaf) where T : unmanaged + private nint Allocate(int length, T fill, bool leaf) where T : unmanaged { int size = sizeof(T) * length; @@ -405,7 +405,7 @@ namespace ARMeilleure.Common } } - page = new AddressTablePage(true, block.Block.Pointer + (IntPtr)_sparseReservedOffset); + page = new AddressTablePage(true, block.Block.Pointer + (nint)_sparseReservedOffset); _sparseReservedOffset += (ulong)size; @@ -413,7 +413,7 @@ namespace ARMeilleure.Common } else { - IntPtr address = (IntPtr)NativeAllocator.Instance.Allocate((uint)size); + nint address = (nint)NativeAllocator.Instance.Allocate((uint)size); page = new AddressTablePage(false, address); Span span = new((void*)page.Address, length); diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs index e7a1afe1a..bfb4b839e 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs @@ -658,7 +658,7 @@ namespace Ryujinx.Graphics.Gpu.Image bool canImport = Storage.Info.IsLinear && Storage.Info.Stride >= Storage.Info.Width * Storage.Info.FormatInfo.BytesPerPixel; - IntPtr hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0; + nint hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0; if (hostPointer != 0 && _context.Renderer.PrepareHostMapping(hostPointer, Storage.Size)) { diff --git a/src/Ryujinx.Graphics.Vulkan/MoltenVK/MVKInitialization.cs b/src/Ryujinx.Graphics.Vulkan/MoltenVK/MVKInitialization.cs index c1c59939e..4f5dbf6b9 100644 --- a/src/Ryujinx.Graphics.Vulkan/MoltenVK/MVKInitialization.cs +++ b/src/Ryujinx.Graphics.Vulkan/MoltenVK/MVKInitialization.cs @@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan.MoltenVK public static void Initialize() { - IntPtr configSize = (nint)Marshal.SizeOf(); + nint configSize = (nint)Marshal.SizeOf(); vkGetMoltenVKConfigurationMVK(nint.Zero, out MVKConfiguration config, configSize); diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanInitialization.cs b/src/Ryujinx.Graphics.Vulkan/VulkanInitialization.cs index c4dbf41f6..02c4e6873 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanInitialization.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanInitialization.cs @@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.Vulkan enabledExtensions = enabledExtensions.Append(ExtDebugUtils.ExtensionName).ToArray(); } - IntPtr appName = Marshal.StringToHGlobalAnsi(AppName); + nint appName = Marshal.StringToHGlobalAnsi(AppName); ApplicationInfo applicationInfo = new() { @@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Vulkan internal static DeviceInfo[] GetSuitablePhysicalDevices(Vk api) { - IntPtr appName = Marshal.StringToHGlobalAnsi(AppName); + nint appName = Marshal.StringToHGlobalAnsi(AppName); ApplicationInfo applicationInfo = new() { diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs index d99488d85..0624fcf91 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs @@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl public bool Blocking { get => Socket.Blocking; set => Socket.Blocking = value; } - public nint Handle => IntPtr.Zero; + public nint Handle => nint.Zero; public IPEndPoint RemoteEndPoint => Socket.RemoteEndPoint as IPEndPoint; diff --git a/src/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs b/src/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs index 344a48be6..4d85fa400 100644 --- a/src/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs +++ b/src/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs @@ -159,7 +159,7 @@ namespace Ryujinx.Memory.WindowsShared { SplitForMap((ulong)location, (ulong)size, srcOffset); - IntPtr ptr = WindowsApi.MapViewOfFile3( + nint ptr = WindowsApi.MapViewOfFile3( sharedMemory, WindowsApi.CurrentProcessHandle, location, diff --git a/src/Ryujinx.Tests/Memory/PartialUnmaps.cs b/src/Ryujinx.Tests/Memory/PartialUnmaps.cs index 73a7f7dfc..313a85a41 100644 --- a/src/Ryujinx.Tests/Memory/PartialUnmaps.cs +++ b/src/Ryujinx.Tests/Memory/PartialUnmaps.cs @@ -227,7 +227,7 @@ namespace Ryujinx.Tests.Memory // Create some info to be used for managing the native writing loop. int stateSize = Unsafe.SizeOf(); - IntPtr statePtr = Marshal.AllocHGlobal(stateSize); + nint statePtr = Marshal.AllocHGlobal(stateSize); Unsafe.InitBlockUnaligned((void*)statePtr, 0, (uint)stateSize); ref NativeWriteLoopState writeLoopState = ref Unsafe.AsRef((void*)statePtr);