Upgrade to .net9
This commit is contained in:
parent
eb97cfb57c
commit
a1cb6592eb
15 changed files with 395 additions and 54 deletions
|
|
@ -7,19 +7,13 @@ namespace StitchATon2.Infra;
|
|||
|
||||
public static class Utils
|
||||
{
|
||||
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "_buffer")]
|
||||
private static extern ref SafeBuffer GetSafeBuffer(this UnmanagedMemoryAccessor view);
|
||||
|
||||
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "_offset")]
|
||||
private static extern ref long GetOffset(this UnmanagedMemoryAccessor view);
|
||||
|
||||
private static unsafe uint AlignedSizeOf<T>() where T : unmanaged
|
||||
{
|
||||
uint size = (uint)sizeof(T);
|
||||
return size is 1 or 2 ? size : (uint)((size + 3) & (~3));
|
||||
}
|
||||
|
||||
public static void DangerousReadSpan<T>(this UnmanagedMemoryAccessor view, long position, Span<T> span, int offset, int count)
|
||||
internal static void DangerousReadSpan<T>(this MemoryMappedViewAccessor view, long position, Span<T> span, int offset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
uint sizeOfT = AlignedSizeOf<T>();
|
||||
|
|
@ -38,8 +32,8 @@ public static class Utils
|
|||
}
|
||||
}
|
||||
|
||||
var byteOffset = (ulong)(view.GetOffset() + position);
|
||||
view.GetSafeBuffer().ReadSpan(byteOffset, span.Slice(offset, n));
|
||||
var byteOffset = (ulong)(view.PointerOffset + position);
|
||||
view.SafeMemoryMappedViewHandle.ReadSpan(byteOffset, span.Slice(offset, n));
|
||||
}
|
||||
|
||||
public static ArrayOwner<T> Clone<T>(this ArrayOwner<T> arrayOwner, int length) where T : unmanaged
|
||||
|
|
@ -48,9 +42,4 @@ public static class Utils
|
|||
Array.Copy(arrayOwner.Array, 0, newArrayOwner.Array, 0, length);
|
||||
return newArrayOwner;
|
||||
}
|
||||
|
||||
public static void CopyTo<T>(this ArrayOwner<T> arrayOwner, ArrayOwner<T> target, int length) where T : unmanaged
|
||||
{
|
||||
Array.Copy(arrayOwner.Array, 0, target.Array, 0, length);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue