]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: memory: declare extended memory API
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 7 Apr 2020 12:13:50 +0000 (14:13 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 7 Apr 2020 15:42:02 +0000 (17:42 +0200)
Windows 10 1803 introduced an extended memory API allowing
to specify memory regions allocations are to be taken off.

In preparation of using this API, define the struct
MEM_EXTENDED_PARAMETER and friends.  Declare and allow to
autoload the functions VirtualAlloc2 and NtMapViewOfSectionEx.

Introduce a wincap flag has_extended_mem_api.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/autoload.cc
winsup/cygwin/ntdll.h
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h
winsup/cygwin/winlean.h

index 8f2fcc1cd6914ffadf939ab5b4ba4b2ac81847b4..613a0199cc89300696715efe35aa55b3e1e40e31 100644 (file)
@@ -597,6 +597,9 @@ LoadDLLfunc (QueryInterruptTime, 4, KernelBase)
 LoadDLLfunc (QueryInterruptTimePrecise, 4, KernelBase)
 LoadDLLfunc (QueryUnbiasedInterruptTime, 4, KernelBase)
 LoadDLLfunc (QueryUnbiasedInterruptTimePrecise, 4, KernelBase)
+LoadDLLfunc (VirtualAlloc2, 28, kernelbase)
+
+LoadDLLfunc (NtMapViewOfSectionEx, 36, ntdll)
 
 /* ldap functions are cdecl! */
 #pragma push_macro ("mangle")
index af1ed5f8d04327573086b67da8d124a4c254a01b..5c6552751f75240d6ce32e869a4150b15e538f03 100644 (file)
@@ -1427,6 +1427,9 @@ extern "C"
   NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG_PTR, SIZE_T,
                                     PLARGE_INTEGER, PSIZE_T, SECTION_INHERIT,
                                     ULONG, ULONG);
+  NTSTATUS NTAPI NtMapViewOfSectionEx (HANDLE, HANDLE, PVOID *, PLARGE_INTEGER,
+                                      PSIZE_T, ULONG, ULONG,
+                                      PMEM_EXTENDED_PARAMETER, ULONG);
   NTSTATUS NTAPI NtNotifyChangeDirectoryFile (HANDLE, HANDLE, PIO_APC_ROUTINE,
                                              PVOID, PIO_STATUS_BLOCK,
                                              PFILE_NOTIFY_INFORMATION, ULONG,
index 922705e6560376d85cfe5bf5df3331b373d7d17d..4d136007fa2cdf93a975a4f58af7b1767a19c59e 100644 (file)
@@ -45,6 +45,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:false,
   },
 };
 
@@ -75,6 +76,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:false,
   },
 };
 
@@ -105,6 +107,7 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:false,
   },
 };
 
@@ -135,6 +138,7 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:false,
   },
 };
 
@@ -165,6 +169,7 @@ wincaps  wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared))
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:false,
   },
 };
 
@@ -195,6 +200,7 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:false,
   },
 };
 
@@ -225,6 +231,7 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:false,
   },
 };
 
@@ -255,6 +262,7 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:true,
   },
 };
 
@@ -285,6 +293,7 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_broken_csi3j:true,
     has_con_broken_il_dl:false,
     has_con_esc_rep:false,
+    has_extended_mem_api:true,
   },
 };
 
@@ -315,6 +324,7 @@ wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:true,
     has_con_esc_rep:true,
+    has_extended_mem_api:true,
   },
 };
 
index 6d7a1eae67c96aa1045cc0c0bd220c125fd4b757..cf13de53506b5bd838f825e2959ab84cc9560116 100644 (file)
@@ -39,6 +39,7 @@ struct wincaps
     unsigned has_con_broken_csi3j              : 1;
     unsigned has_con_broken_il_dl              : 1;
     unsigned has_con_esc_rep                   : 1;
+    unsigned has_extended_mem_api              : 1;
   };
 };
 
@@ -101,6 +102,7 @@ public:
   bool IMPLEMENT (has_con_broken_csi3j)
   bool IMPLEMENT (has_con_broken_il_dl)
   bool IMPLEMENT (has_con_esc_rep)
+  bool IMPLEMENT (has_extended_mem_api)
 
   void disable_case_sensitive_dirs ()
   {
index 9b30b6557c4f8f674e3694b85d68774d0e7ee1c1..2ee4aaff463d83022b65d8db95ccb050b2566c13 100644 (file)
@@ -94,4 +94,55 @@ details. */
 #define GetWindowsDirectoryW dont_use_GetWindowsDirectory
 #define GetWindowsDirectoryA dont_use_GetWindowsDirectory
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Define extended memory API here as long as not available from mingw-w64. */
+
+typedef struct _MEM_ADDRESS_REQUIREMENTS
+{
+  PVOID LowestStartingAddress;
+  PVOID HighestEndingAddress;
+  SIZE_T Alignment;
+} MEM_ADDRESS_REQUIREMENTS, *PMEM_ADDRESS_REQUIREMENTS;
+
+typedef enum MEM_EXTENDED_PARAMETER_TYPE
+{
+  MemExtendedParameterInvalidType = 0,
+  MemExtendedParameterAddressRequirements,
+  MemExtendedParameterNumaNode,
+  MemExtendedParameterPartitionHandle,
+  MemExtendedParameterUserPhysicalHandle,
+  MemExtendedParameterAttributeFlags,
+  MemExtendedParameterMax
+} MEM_EXTENDED_PARAMETER_TYPE, *PMEM_EXTENDED_PARAMETER_TYPE;
+
+#define MEM_EXTENDED_PARAMETER_TYPE_BITS 8
+
+typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER
+{
+  struct
+  {
+      DWORD64 Type : MEM_EXTENDED_PARAMETER_TYPE_BITS;
+      DWORD64 Reserved : 64 - MEM_EXTENDED_PARAMETER_TYPE_BITS;
+  };
+  union
+  {
+      DWORD64 ULong64;
+      PVOID Pointer;
+      SIZE_T Size;
+      HANDLE Handle;
+      DWORD ULong;
+  };
+} MEM_EXTENDED_PARAMETER, *PMEM_EXTENDED_PARAMETER;
+
+PVOID VirtualAlloc2 (HANDLE, PVOID, SIZE_T, ULONG, ULONG,
+                    PMEM_EXTENDED_PARAMETER, ULONG);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /*_WINLEAN_H*/
This page took 0.04496 seconds and 5 git commands to generate.