]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: Make sure newer apps get uname_x even when loading uname dynamically
authorCorinna Vinschen <corinna@vinschen.de>
Mon, 14 Dec 2020 11:29:23 +0000 (12:29 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 15 Dec 2020 12:05:13 +0000 (13:05 +0100)
if an application built after API version 334 loads uname dynamically,
it actually gets the old uname, rather than the new uname_x.  Fix this by
checking the apps API version in uname and call uname_x instead, if it's
a newer app.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/include/cygwin/version.h
winsup/cygwin/uname.cc

index f21aba72669a54006723924e99787b5b2a0846ba..b39d0dbe95bb9a2d5d92775fbb80e9e21dbc9ace 100644 (file)
@@ -74,6 +74,9 @@ details. */
 #define CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS \
   (CYGWIN_VERSION_USER_API_VERSION_COMBINED >= 272)
 
+#define CYGWIN_VERSION_CHECK_FOR_UNAME_X \
+  (CYGWIN_VERSION_USER_API_VERSION_COMBINED >= 335)
+
 #define CYGWIN_VERSION_CYGWIN_CONV 181
 
 /* API_MAJOR 0.0: Initial version.  API_MINOR changes:
index 350216681fa13712188045740b9732c71d7a8b21..48f7dda6029b62578a320832651f738e8d19b8e2 100644 (file)
@@ -92,7 +92,14 @@ struct old_utsname
 extern "C" int
 uname (struct utsname *in_name)
 {
+  /* This occurs if the application fetches the uname symbol dynamically.
+     We must call uname_x for newer API versions, otherwise the idea of
+     struct utsname doesn't match. */
+  if (CYGWIN_VERSION_CHECK_FOR_UNAME_X)
+    return uname_x (in_name);
+
   struct old_utsname *name = (struct old_utsname *) in_name;
+
   __try
     {
       char *snp = strstr  (cygwin_version.dll_build_date, "SNP");
This page took 0.033329 seconds and 5 git commands to generate.