mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-27 01:37:11 +02:00
Structural and Memory Safety Improvements, Analyzer Cleanup (ryubing/ryujinx!47)
See merge request ryubing/ryujinx!47
This commit is contained in:
parent
d03ae9c164
commit
ea027d65a7
309 changed files with 1018 additions and 1247 deletions
|
@ -1,5 +1,6 @@
|
|||
using NUnit.Framework;
|
||||
using Ryujinx.Common.Extensions;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
@ -274,11 +275,12 @@ namespace Ryujinx.Tests.Common.Extensions
|
|||
public short EffectsSize;
|
||||
public int RenderInfoSize;
|
||||
|
||||
public unsafe fixed byte Reserved[16];
|
||||
//public unsafe fixed byte Reserved[16];
|
||||
public Buffer16 Reserved;
|
||||
|
||||
public static readonly int SizeOf = Unsafe.SizeOf<MyUnmanagedStruct>();
|
||||
|
||||
public static unsafe MyUnmanagedStruct Generate(Random rng)
|
||||
public static MyUnmanagedStruct Generate(Random rng)
|
||||
{
|
||||
const int BaseInt32Value = 0x1234abcd;
|
||||
const short BaseInt16Value = 0x5678;
|
||||
|
@ -293,7 +295,8 @@ namespace Ryujinx.Tests.Common.Extensions
|
|||
RenderInfoSize = BaseInt32Value ^ rng.Next(),
|
||||
};
|
||||
|
||||
Unsafe.Write(result.Reserved, rng.NextInt64());
|
||||
Span<byte> reservedSpan = result.Reserved.Bytes;
|
||||
rng.NextBytes(reservedSpan);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -307,14 +310,7 @@ namespace Ryujinx.Tests.Common.Extensions
|
|||
assert(expected.EffectsSize, actual.EffectsSize);
|
||||
assert(expected.RenderInfoSize, actual.RenderInfoSize);
|
||||
|
||||
fixed (void* expectedReservedPtr = expected.Reserved)
|
||||
fixed (void* actualReservedPtr = actual.Reserved)
|
||||
{
|
||||
long expectedReservedLong = Unsafe.Read<long>(expectedReservedPtr);
|
||||
long actualReservedLong = Unsafe.Read<long>(actualReservedPtr);
|
||||
|
||||
assert(expectedReservedLong, actualReservedLong);
|
||||
}
|
||||
assert(expected.Reserved, actual.Reserved);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,7 @@ namespace Ryujinx.Tests.Memory
|
|||
|
||||
public MemoryManagerType Type => MemoryManagerType.HostMappedUnsafe;
|
||||
|
||||
#pragma warning disable CS0067 // The event is never used
|
||||
public event Action<ulong, ulong> UnmapEvent;
|
||||
#pragma warning restore CS0067
|
||||
|
||||
public ref T GetRef<T>(ulong va) where T : unmanaged
|
||||
{
|
||||
|
@ -49,5 +47,12 @@ namespace Ryujinx.Tests.Memory
|
|||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
// Since the mock never unmaps memory, the UnmapEvent is never used and this causes a warning.
|
||||
// This method is provided to allow the mock to trigger the event if needed.
|
||||
public void Unmap(ulong va, ulong size)
|
||||
{
|
||||
UnmapEvent?.Invoke(va, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ using Ryujinx.Memory;
|
|||
using Ryujinx.Memory.Tracking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue