{
internal static partial class Sys
{
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FTruncate", SetLastError = true)]
- internal static extern int FTruncate(SafeFileHandle fd, long length);
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FTruncate", SetLastError = true)]
+ internal static partial int FTruncate(SafeFileHandle fd, long length);
}
}
{
internal static partial class Sys
{
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MAdvise", SetLastError = true)]
- internal static extern int MAdvise(IntPtr addr, ulong length, MemoryAdvice advice);
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MAdvise", SetLastError = true)]
+ internal static partial int MAdvise(IntPtr addr, ulong length, MemoryAdvice advice);
internal enum MemoryAdvice
{
}
// NOTE: Shim returns null pointer on failure, not non-null MAP_FAILED sentinel.
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MMap", SetLastError = true)]
- internal static extern IntPtr MMap(
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MMap", SetLastError = true)]
+ internal static partial IntPtr MMap(
IntPtr addr, ulong len,
MemoryMappedProtections prot, MemoryMappedFlags flags,
SafeFileHandle fd, long offset);
MS_INVALIDATE = 0x10,
}
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MSync", SetLastError = true)]
- internal static extern int MSync(IntPtr addr, ulong len, MemoryMappedSyncFlags flags);
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MSync", SetLastError = true)]
+ internal static partial int MSync(IntPtr addr, ulong len, MemoryMappedSyncFlags flags);
}
}
{
internal static partial class Sys
{
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MUnmap", SetLastError = true)]
- internal static extern int MUnmap(IntPtr addr, ulong len);
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MUnmap", SetLastError = true)]
+ internal static partial int MUnmap(IntPtr addr, ulong len);
}
}
{
internal static partial class Sys
{
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmOpen", SetLastError = true)]
- internal static extern SafeFileHandle ShmOpen(string name, OpenFlags flags, int mode);
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmOpen", SetLastError = true, CharSet = CharSet.Ansi)]
+ internal static partial SafeFileHandle ShmOpen(string name, OpenFlags flags, int mode);
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmUnlink", SetLastError = true)]
- internal static extern int ShmUnlink(string name);
+ [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ShmUnlink", SetLastError = true, CharSet = CharSet.Ansi)]
+ internal static partial int ShmUnlink(string name);
}
}
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ internal static partial SafeMemoryMappedFileHandle CreateFileMapping(
+#else
[DllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern SafeMemoryMappedFileHandle CreateFileMapping(
+#endif
SafeFileHandle hFile,
ref SECURITY_ATTRIBUTES lpFileMappingAttributes,
int flProtect,
int dwMaximumSizeLow,
string? lpName);
+#if DLLIMPORTGENERATOR_ENABLED
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ internal static partial SafeMemoryMappedFileHandle CreateFileMapping(
+#else
[DllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern SafeMemoryMappedFileHandle CreateFileMapping(
+#endif
IntPtr hFile,
ref SECURITY_ATTRIBUTES lpFileMappingAttributes,
int flProtect,
{
internal static partial class Kernel32
{
- [DllImport(Libraries.Kernel32, SetLastError = true)]
- internal static extern bool FlushViewOfFile(IntPtr lpBaseAddress, UIntPtr dwNumberOfBytesToFlush);
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+ internal static partial bool FlushViewOfFile(IntPtr lpBaseAddress, UIntPtr dwNumberOfBytesToFlush);
}
}
internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
- internal static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
+ internal static unsafe extern int GlobalMemoryStatusEx(MEMORYSTATUSEX* lpBuffer);
}
}
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MapViewOfFile", CharSet = CharSet.Unicode, SetLastError = true)]
+ internal static partial SafeMemoryMappedViewHandle MapViewOfFile(
+#else
[DllImport(Libraries.Kernel32, EntryPoint = "MapViewOfFile", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern SafeMemoryMappedViewHandle MapViewOfFile(
+#endif
SafeMemoryMappedFileHandle hFileMappingObject,
int dwDesiredAccess,
int dwFileOffsetHigh,
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ internal static partial SafeMemoryMappedFileHandle OpenFileMapping(
+#else
[DllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern SafeMemoryMappedFileHandle OpenFileMapping(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, string lpName);
+ internal static extern SafeMemoryMappedFileHandle OpenFileMapping(
+#endif
+ int dwDesiredAccess,
+ [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle,
+ string lpName);
}
}
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+ internal static partial bool UnmapViewOfFile(IntPtr lpBaseAddress);
+#else
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool UnmapViewOfFile(IntPtr lpBaseAddress);
+#endif
}
}
{
internal static partial class Kernel32
{
- [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
- internal static extern IntPtr VirtualAlloc(SafeHandle lpAddress, UIntPtr dwSize, int flAllocationType, int flProtect);
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
+ internal static partial IntPtr VirtualAlloc(SafeHandle lpAddress, UIntPtr dwSize, int flAllocationType, int flProtect);
}
}
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
+ [GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
+ internal static partial UIntPtr VirtualQuery(
+#else
[DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
- internal static extern UIntPtr VirtualQuery(SafeHandle lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength);
+ internal static extern UIntPtr VirtualQuery(
+#endif
+ SafeHandle lpAddress,
+ ref MEMORY_BASIC_INFORMATION lpBuffer,
+ UIntPtr dwLength);
}
}
{
Interop.Kernel32.MEMORYSTATUSEX memoryStatus = default;
memoryStatus.dwLength = (uint)sizeof(Interop.Kernel32.MEMORYSTATUSEX);
- if (Interop.Kernel32.GlobalMemoryStatusEx(ref memoryStatus))
+ if (Interop.Kernel32.GlobalMemoryStatusEx(&memoryStatus) != 0)
{
ulong totalVirtual = memoryStatus.ullTotalVirtual;
if (nativeSize >= totalVirtual)
{
Interop.Kernel32.MEMORYSTATUSEX memoryStatus = default;
memoryStatus.dwLength = (uint)sizeof(Interop.Kernel32.MEMORYSTATUSEX);
- if (!Interop.Kernel32.GlobalMemoryStatusEx(ref memoryStatus))
+ if (Interop.Kernel32.GlobalMemoryStatusEx(&memoryStatus) == 0)
{
availPageFile = default;
totalAddressSpaceFree = default;
{
Interop.Kernel32.MEMORYSTATUSEX memoryStatus = default;
memoryStatus.dwLength = (uint)sizeof(Interop.Kernel32.MEMORYSTATUSEX);
- if (Interop.Kernel32.GlobalMemoryStatusEx(ref memoryStatus))
+ if (Interop.Kernel32.GlobalMemoryStatusEx(&memoryStatus) != 0)
{
s_totalPhysical = (long)memoryStatus.ullTotalPhys;
s_totalVirtual = (long)memoryStatus.ullTotalVirtual;
{
Interop.Kernel32.MEMORYSTATUSEX memoryStatus = default;
memoryStatus.dwLength = (uint)sizeof(Interop.Kernel32.MEMORYSTATUSEX);
- if (!Interop.Kernel32.GlobalMemoryStatusEx(ref memoryStatus))
+ if (Interop.Kernel32.GlobalMemoryStatusEx(&memoryStatus) == 0)
{
return 0;
}