You've already forked linux-packaging-mono
Imported Upstream version 5.16.0.100
Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
parent
0a9828183b
commit
7d7f676260
@ -1,3 +1,12 @@
|
||||
#if BIT64
|
||||
using nuint = System.UInt64;
|
||||
#else
|
||||
using nuint = System.UInt32;
|
||||
#endif
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime;
|
||||
|
||||
namespace System
|
||||
{
|
||||
partial class Buffer
|
||||
@ -213,7 +222,28 @@ namespace System
|
||||
|
||||
internal static unsafe void Memmove (byte *dest, byte *src, uint len)
|
||||
{
|
||||
if (((nuint)dest - (nuint)src < len) || ((nuint)src - (nuint)dest < len))
|
||||
goto PInvoke;
|
||||
Memcpy (dest, src, (int) len);
|
||||
return;
|
||||
|
||||
PInvoke:
|
||||
RuntimeImports.Memmove(dest, src, len);
|
||||
}
|
||||
|
||||
internal static void Memmove<T>(ref T destination, ref T source, nuint elementCount)
|
||||
{
|
||||
if (!RuntimeHelpers.IsReferenceOrContainsReferences<T>()) {
|
||||
unsafe {
|
||||
fixed (byte* pDestination = &Unsafe.As<T, byte>(ref destination), pSource = &Unsafe.As<T, byte>(ref source))
|
||||
Memmove(pDestination, pSource, (uint)elementCount * (uint)Unsafe.SizeOf<T>());
|
||||
}
|
||||
} else {
|
||||
unsafe {
|
||||
fixed (byte* pDestination = &Unsafe.As<T, byte>(ref destination), pSource = &Unsafe.As<T, byte>(ref source))
|
||||
RuntimeImports.Memmove_wbarrier(pDestination, pSource, (uint)elementCount, typeof(T).TypeHandle.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user