From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 7ADDE384B00F; Tue, 15 Dec 2020 12:05:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7ADDE384B00F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: Make sure newer apps get uname_x even when loading uname dynamically X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 6cc47c4c330a6468dd8a42b88f97c5aaecad3cdb X-Git-Newrev: 532b91d24e9496c7988b2b1dda7fc0e8b161f782 Message-Id: <20201215120527.7ADDE384B00F@sourceware.org> Date: Tue, 15 Dec 2020 12:05:27 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2020 12:05:27 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=532b91d24e9496c7988b2b1dda7fc0e8b161f782 commit 532b91d24e9496c7988b2b1dda7fc0e8b161f782 Author: Corinna Vinschen Date: Mon Dec 14 12:29:23 2020 +0100 Cygwin: Make sure newer apps get uname_x even when loading uname dynamically 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 Diff: --- winsup/cygwin/include/cygwin/version.h | 3 +++ winsup/cygwin/uname.cc | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index f21aba726..b39d0dbe9 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -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: diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc index 350216681..48f7dda60 100644 --- a/winsup/cygwin/uname.cc +++ b/winsup/cygwin/uname.cc @@ -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");