[PATCH] Cygwin: winlean.h: remove most of extended memory API

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Cygwin: winlean.h: remove most of extended memory API

cygwin-patches mailing list
This was added as a temporary measure in commit e18f7f99 because it
wasn't yet in the mingw-w64 headers.  With one exception, it is now in
the current release of the headers (version 8.0.0), so we don't need
it in winlean.h.  The exception is that VirtualAlloc2 is only declared
conditionally in <w32api/memoryapi.h>, so retain it in winlean.h.  Add
"WINAPI" to its declaration for consistency with the delaration in
memoryapi.h.

Also revert commit 3d136011, which was a related temporary workaround.
---
 winsup/cygwin/winlean.h | 44 +++--------------------------------------
 winsup/utils/cygpath.cc |  1 -
 winsup/utils/ps.cc      |  1 -
 3 files changed, 3 insertions(+), 43 deletions(-)

diff --git a/winsup/cygwin/winlean.h b/winsup/cygwin/winlean.h
index 2ee4aaff4..4a6a46355 100644
--- a/winsup/cygwin/winlean.h
+++ b/winsup/cygwin/winlean.h
@@ -99,47 +99,9 @@ details. */
 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);
+
+PVOID WINAPI VirtualAlloc2 (HANDLE, PVOID, SIZE_T, ULONG, ULONG,
+    PMEM_EXTENDED_PARAMETER, ULONG);
 
 #ifdef __cplusplus
 }
diff --git a/winsup/utils/cygpath.cc b/winsup/utils/cygpath.cc
index aa9df3a21..bc5f11dd0 100644
--- a/winsup/utils/cygpath.cc
+++ b/winsup/utils/cygpath.cc
@@ -24,7 +24,6 @@ details. */
 #define _WIN32_WINNT 0x0a00
 #define WINVER 0x0a00
 #define NOCOMATTRIBUTE
-#define PMEM_EXTENDED_PARAMETER PVOID
 #include <windows.h>
 #include <userenv.h>
 #include <shlobj.h>
diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc
index f3eb9e847..478ed8efd 100644
--- a/winsup/utils/ps.cc
+++ b/winsup/utils/ps.cc
@@ -6,7 +6,6 @@ This software is a copyrighted work licensed under the terms of the
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
-#define PMEM_EXTENDED_PARAMETER PVOID
 #include <errno.h>
 #include <stdio.h>
 #include <locale.h>
--
2.28.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: winlean.h: remove most of extended memory API

Jon TURNEY
On 24/09/2020 00:52, Ken Brown via Cygwin-patches wrote:
> This was added as a temporary measure in commit e18f7f99 because it
> wasn't yet in the mingw-w64 headers.  With one exception, it is now in
> the current release of the headers (version 8.0.0), so we don't need
> it in winlean.h.  The exception is that VirtualAlloc2 is only declared
> conditionally in <w32api/memoryapi.h>, so retain it in winlean.h.  Add

I assume it's conditional on the windows version targetted, but it might
help to mention that in a comment.

> "WINAPI" to its declaration for consistency with the delaration in
> memoryapi.h.
>
> Also revert commit 3d136011, which was a related temporary workaround.

Looks good to me.

I think this isn't going work any more with older win32api, but we
probably don't care about that.  It would perhaps be nice to explicitly
complain about that (checking __MINGW64_VERSION_MAJOR somehow), rather
than exploding incomprehensibly if the w32api is too old?

> In particular, I'd like to know if my handling of the
> declaration of VirtualAlloc2 seems reasonable.  Among other things, I'm
> puzzled by the apparent need to add WINAPI.  If it's really needed, I
> don't know how the calls of that function could have worked before.  Can
> anyone enlighten me?

I believe that WINAPI only does something (stdcall) on x86, so it might
well be that it's never worked on Windows 10 =>1803 x86?

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: winlean.h: remove most of extended memory API

cygwin-patches mailing list
On 9/24/2020 10:04 AM, Jon Turney wrote:
> On 24/09/2020 00:52, Ken Brown via Cygwin-patches wrote:
>> This was added as a temporary measure in commit e18f7f99 because it
>> wasn't yet in the mingw-w64 headers.  With one exception, it is now in
>> the current release of the headers (version 8.0.0), so we don't need
>> it in winlean.h.  The exception is that VirtualAlloc2 is only declared
>> conditionally in <w32api/memoryapi.h>, so retain it in winlean.h.  Add
>
> I assume it's conditional on the windows version targetted, but it might help to
> mention that in a comment.

Done.

>> "WINAPI" to its declaration for consistency with the delaration in
>> memoryapi.h.
>>
>> Also revert commit 3d136011, which was a related temporary workaround.
>
> Looks good to me.
>
> I think this isn't going work any more with older win32api, but we probably
> don't care about that.  It would perhaps be nice to explicitly complain about
> that (checking __MINGW64_VERSION_MAJOR somehow), rather than exploding
> incomprehensibly if the w32api is too old?

We probably don't care much, since anyone building Cygwin should have the latest
tools installed.  On the other hand, it's simple to add that check, so I've done it.

>> In particular, I'd like to know if my handling of the declaration of
>> VirtualAlloc2 seems reasonable.  Among other things, I'm puzzled by the
>> apparent need to add WINAPI.  If it's really needed, I don't know how the
>> calls of that function could have worked before.  Can anyone enlighten me?
>
> I believe that WINAPI only does something (stdcall) on x86, so it might well be
> that it's never worked on Windows 10 =>1803 x86?

OK, I feel better now.

Thanks for the review.

Ken
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: winlean.h: remove most of extended memory API

Corinna Vinschen-2
In reply to this post by Jon TURNEY
On Sep 24 15:04, Jon Turney wrote:

> On 24/09/2020 00:52, Ken Brown via Cygwin-patches wrote:
> > This was added as a temporary measure in commit e18f7f99 because it
> > wasn't yet in the mingw-w64 headers.  With one exception, it is now in
> > the current release of the headers (version 8.0.0), so we don't need
> > it in winlean.h.  The exception is that VirtualAlloc2 is only declared
> > conditionally in <w32api/memoryapi.h>, so retain it in winlean.h.  Add
>
> I assume it's conditional on the windows version targetted, but it might
> help to mention that in a comment.
>
> > "WINAPI" to its declaration for consistency with the delaration in
> > memoryapi.h.
> >
> > Also revert commit 3d136011, which was a related temporary workaround.
>
> Looks good to me.
>
> I think this isn't going work any more with older win32api, but we probably
> don't care about that.  It would perhaps be nice to explicitly complain
> about that (checking __MINGW64_VERSION_MAJOR somehow), rather than exploding
> incomprehensibly if the w32api is too old?
>
> > In particular, I'd like to know if my handling of the declaration of
> > VirtualAlloc2 seems reasonable.  Among other things, I'm puzzled by the
> > apparent need to add WINAPI.  If it's really needed, I don't know how
> > the calls of that function could have worked before.  Can anyone
> > enlighten me?
>
> I believe that WINAPI only does something (stdcall) on x86, so it might well
> be that it's never worked on Windows 10 =>1803 x86?

VirtualAlloc2 is only called in x86_64 code, so the WINAPI was not
required.  x86 is a lost case in terms of memory allocation anyway.


Corinna