public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-patches@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH] Define PSAPI_VERSION as 1 before including psapi.h
Date: Sun, 20 Jun 2021 14:37:27 +0100	[thread overview]
Message-ID: <20210620133727.63966-1-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <96d77c6b-0b46-527e-40bb-40adca640aff@dronecode.org.uk>

The default PSAPI_VERSION is controlled by WIN32_WINNT, which we set to
0x0a00 when building utils since 48a76190 (and is the default in w32api
>= 9.0.0)

In order for the built executables to run on Windows Vista, we must also
define PSAPI_VERSION as 1 (otherwise '#define GetModuleFileNameExA
K32GetModuleFileNameExA' causes a 'The procedure entry point
K32GetModuleFilenameExA could not be located in the dynamic link library
kernel32.dll' error at run time).

Also drop uneeded psapi.h from dlfcn.cc (31ddf45d), resource.cc
(34a6eeab) and ps.cc (1def2148).
---
 winsup/cygwin/dlfcn.cc      | 1 -
 winsup/cygwin/resource.cc   | 1 -
 winsup/utils/dumper.cc      | 1 +
 winsup/utils/ldd.cc         | 2 +-
 winsup/utils/mingw/bloda.cc | 1 +
 winsup/utils/module_info.cc | 1 +
 winsup/utils/pldd.c         | 1 +
 winsup/utils/ps.cc          | 1 -
 8 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc
index c675a5785..9a7472850 100644
--- a/winsup/cygwin/dlfcn.cc
+++ b/winsup/cygwin/dlfcn.cc
@@ -7,7 +7,6 @@ Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
 #include "winsup.h"
-#include <psapi.h>
 #include <stdlib.h>
 #include <dlfcn.h>
 #include <ctype.h>
diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc
index 97777e9d2..1664bca0f 100644
--- a/winsup/cygwin/resource.cc
+++ b/winsup/cygwin/resource.cc
@@ -14,7 +14,6 @@ details. */
 #include <unistd.h>
 #include <sys/param.h>
 #include "pinfo.h"
-#include "psapi.h"
 #include "cygtls.h"
 #include "path.h"
 #include "fhandler.h"
diff --git a/winsup/utils/dumper.cc b/winsup/utils/dumper.cc
index f21c93bf7..bc6c68a53 100644
--- a/winsup/utils/dumper.cc
+++ b/winsup/utils/dumper.cc
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <sys/param.h>
 #include <windows.h>
+#define PSAPI_VERSION 1
 #include <psapi.h>
 
 #include "dumper.h"
diff --git a/winsup/utils/ldd.cc b/winsup/utils/ldd.cc
index f9b04ed10..0d073c298 100644
--- a/winsup/utils/ldd.cc
+++ b/winsup/utils/ldd.cc
@@ -37,10 +37,10 @@
 #include <unistd.h>
 #include <libgen.h>
 
-#define PSAPI_VERSION 1
 #include <windows.h>
 #include <winternl.h>
 #include <imagehlp.h>
+#define PSAPI_VERSION 1
 #include <psapi.h>
 
 struct option longopts[] =
diff --git a/winsup/utils/mingw/bloda.cc b/winsup/utils/mingw/bloda.cc
index ffaee5229..330ac556f 100644
--- a/winsup/utils/mingw/bloda.cc
+++ b/winsup/utils/mingw/bloda.cc
@@ -13,6 +13,7 @@
 			   ntstatus.h for extended status codes below. */
 #include <windows.h>
 #undef WIN32_NO_STATUS
+#define PSAPI_VERSION 1
 #include <psapi.h>
 #include <winternl.h>
 #include <ntstatus.h>
diff --git a/winsup/utils/module_info.cc b/winsup/utils/module_info.cc
index bf3a18bf3..e0bd4b71a 100644
--- a/winsup/utils/module_info.cc
+++ b/winsup/utils/module_info.cc
@@ -10,6 +10,7 @@ details. */
 
 #include <stdlib.h>
 #include <windows.h>
+#define PSAPI_VERSION 1
 #include <psapi.h>
 #include "loadlib.h"
 
diff --git a/winsup/utils/pldd.c b/winsup/utils/pldd.c
index f077e63ab..2c085eaa2 100644
--- a/winsup/utils/pldd.c
+++ b/winsup/utils/pldd.c
@@ -16,6 +16,7 @@ details. */
 #include <sys/cygwin.h>
 #include <cygwin/version.h>
 #include <windows.h>
+#define PSAPI_VERSION 1
 #include <psapi.h>
 
 struct option longopts[] =
diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc
index 478ed8efd..b51657535 100644
--- a/winsup/utils/ps.cc
+++ b/winsup/utils/ps.cc
@@ -19,7 +19,6 @@ details. */
 #include <limits.h>
 #include <sys/cygwin.h>
 #include <cygwin/version.h>
-#include <psapi.h>
 #include <ntdef.h>
 #include <ntdll.h>
 #include "loadlib.h"
-- 
2.31.1


  reply	other threads:[~2021-06-20 13:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 17:46 [PATCH] Ensure PSAPI_VERSION is 1 when building ldd Jon Turney
2021-05-20 18:05 ` Corinna Vinschen
2021-05-22 15:08   ` Jon Turney
2021-05-25 21:37     ` Jon Turney
2021-05-26  9:04       ` Corinna Vinschen
2021-05-26 16:51         ` Jon Turney
2021-05-26 17:04           ` Yaakov Selkowitz
2021-05-26 19:18             ` Corinna Vinschen
2021-05-27 17:30               ` Jon Turney
2021-05-27 19:08                 ` Corinna Vinschen
2021-05-28 15:13                   ` Jon Turney
2021-06-20 13:37                     ` Jon Turney [this message]
2021-07-06 13:55                       ` [PATCH] Define PSAPI_VERSION as 1 before including psapi.h Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210620133727.63966-1-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).