static MsVcRt() { _hModule = NativeLibrary.Load(_moduleName); MemSet = (MemSetDelegate)Marshal.GetDelegateForFunctionPointer(NativeLibrary.GetExport(_hModule, "memset"), typeof(MemSetDelegate)); MemICmp = (MemICmpDelegate)Marshal.GetDelegateForFunctionPointer(NativeLibrary.GetExport(_hModule, "_memicmp"), typeof(MemICmpDelegate)); MemCpy = (MemCpyDelegate)Marshal.GetDelegateForFunctionPointer(NativeLibrary.GetExport(_hModule, "memcpy"), typeof(MemCpyDelegate)); }
static UnsafeNativeMethods() { #if NETSTANDARD || NETCOREAPP if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { MemcmpFunc = memcmp_linux; MemcpyFunc = memcpy_linux; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { MemcmpFunc = memcmp_osx; MemcpyFunc = memcpy_osx; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { MemcmpFunc = memcmp_win; MemcpyFunc = memcpy_win; } #else MemcmpFunc = memcmp_win; MemcpyFunc = memcpy_win; #endif }