diff options
Diffstat (limited to 'YesCommander/Assets/ThirdParty/UnsafeFunction.cs')
-rw-r--r-- | YesCommander/Assets/ThirdParty/UnsafeFunction.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/YesCommander/Assets/ThirdParty/UnsafeFunction.cs b/YesCommander/Assets/ThirdParty/UnsafeFunction.cs new file mode 100644 index 0000000..3362626 --- /dev/null +++ b/YesCommander/Assets/ThirdParty/UnsafeFunction.cs @@ -0,0 +1,53 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + + + +public class UnsafeFunction +{ + + public unsafe static void memcpyimpl(byte* src, byte* dest, int len) + { + if (len >= 16) + { + do + { + *(int*)dest = *(int*)src; + *(int*)(dest + 4) = *(int*)(src + 4); + *(int*)(dest + 8) = *(int*)(src + 8); + *(int*)(dest + 12) = *(int*)(src + 12); + dest += 16; + src += 16; + } + while ((len -= 16) >= 16); + } + if (len > 0) + { + if ((len & 8) != 0) + { + *(int*)dest = *(int*)src; + *(int*)(dest + 4) = *(int*)(src + 4); + dest += 8; + src += 8; + } + if ((len & 4) != 0) + { + *(int*)dest = *(int*)src; + dest += 4; + src += 4; + } + if ((len & 2) != 0) + { + *(short*)dest = *(short*)src; + dest += 2; + src += 2; + } + if ((len & 1) != 0) + { + *(dest++) = *(src++); + } + } + } + +}
\ No newline at end of file |