From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by sourceware.org (Postfix) with ESMTPS id 9A2083858C83 for ; Tue, 20 Dec 2022 10:42:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A2083858C83 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BK9vWcg003126; Tue, 20 Dec 2022 11:42:21 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=QcXVVTqROhrWHJ+9Cf3kU+cDntqwNuib/lQycTW8wFY=; b=Oy5XXZfjPylKjaqo1uHXzZQXLy8W4B/t9/vHku+yCGQMl62ZT/vWKXWFRT/NCsLyTeSE 70eV225Wo3JSeSkaipfOwLxUcxLlVFfQeG+VKq0Ct1eIl7YRk4j9AkqLrJpMuTRMhzeg SjGfNygCKRhEgiq+BEBtAUTzQMaiGRW8LYK7lPisWyqHrVpZcYv18+X3FhAt7n+9E2z1 okuqfvAmL1QmhEqTBLCIGl3vJ0lLnZHkC7jDOc/Qemmza6zeTG0DgfNHEuO1ij8zLgsw XB2OkzZAAvRU1HzrhQRs7FtZhqQHIBFc8tfA1gPyMxH6s2scnN0R0sZNMY4ABXNs5L7J QA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3mh42pg0n7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Dec 2022 11:42:21 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7FD9310002A; Tue, 20 Dec 2022 11:42:16 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 79943217B7A; Tue, 20 Dec 2022 11:42:16 +0100 (CET) Received: from [10.252.5.234] (10.252.5.234) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.13; Tue, 20 Dec 2022 11:42:14 +0100 Message-ID: <7fd0614d-775e-7a5a-cc09-1feda4cbb508@foss.st.com> Date: Tue, 20 Dec 2022 11:42:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: PR29915, bfdio.c does not compile with mingw.org's MinGW Content-Language: en-US To: Alan Modra , References: From: Torbjorn SVENSSON In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.252.5.234] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-20_03,2022-12-20_01,2022-06-22_01 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2022-12-20 09:34, Alan Modra wrote: > PR 29915 > * configure.ac: Add AC_CHECK_DECLS test ___lc_codepage_func. > * configure: Regenerate. > * config.in: Regenerate. > * bfdio.c (___lc_codepage_func): Move declaration to.. > (_bfd_real_fopen): ..here, and use !HAVE_DECL____LC_CODEPAGE_FUNC. > > diff --git a/bfd/bfdio.c b/bfd/bfdio.c > index 571f12b625a..a67d4bbbeb7 100644 > --- a/bfd/bfdio.c > +++ b/bfd/bfdio.c > @@ -31,11 +31,6 @@ > #include > #endif > > -#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9 > -/* This prototype was added to locale.h in version 9.0 of MinGW-w64. */ > -_CRTIMP unsigned int __cdecl ___lc_codepage_func(void); > -#endif > - > #ifndef S_IXUSR > #define S_IXUSR 0100 /* Execute by owner. */ > #endif > @@ -127,7 +122,11 @@ _bfd_real_fopen (const char *filename, const char *modes) > const wchar_t prefix[] = L"\\\\?\\"; > const size_t partPathLen = strlen (filename) + 1; > #ifdef __MINGW32__ > - const unsigned int cp = ___lc_codepage_func(); > +#if !HAVE_DECL____LC_CODEPAGE_FUNC > +/* This prototype was added to locale.h in version 9.0 of MinGW-w64. */ > + _CRTIMP unsigned int __cdecl ___lc_codepage_func (void); > +#endif > + const unsigned int cp = ___lc_codepage_func (); > #else > const unsigned int cp = CP_UTF8; > #endif > diff --git a/bfd/config.in b/bfd/config.in > index a59304e0a66..e5132df393c 100644 > --- a/bfd/config.in > +++ b/bfd/config.in > @@ -64,6 +64,10 @@ > don't. */ > #undef HAVE_DECL_VASPRINTF > > +/* Define to 1 if you have the declaration of `___lc_codepage_func', and to 0 > + if you don't. */ > +#undef HAVE_DECL____LC_CODEPAGE_FUNC > + > /* Define to 1 if you have the header file. */ > #undef HAVE_DLFCN_H > > diff --git a/bfd/configure b/bfd/configure > index b532fe7e8af..31dfac508a2 100755 > --- a/bfd/configure > +++ b/bfd/configure > @@ -13006,6 +13006,18 @@ cat >>confdefs.h <<_ACEOF > #define HAVE_DECL_STRNLEN $ac_have_decl > _ACEOF > > +ac_fn_c_check_decl "$LINENO" "___lc_codepage_func" "ac_cv_have_decl____lc_codepage_func" "#include > +" > +if test "x$ac_cv_have_decl____lc_codepage_func" = xyes; then : > + ac_have_decl=1 > +else > + ac_have_decl=0 > +fi > + > +cat >>confdefs.h <<_ACEOF > +#define HAVE_DECL____LC_CODEPAGE_FUNC $ac_have_decl > +_ACEOF > + > > > case "${host}" in > diff --git a/bfd/configure.ac b/bfd/configure.ac > index 45a293d0bcb..da6933bffc6 100644 > --- a/bfd/configure.ac > +++ b/bfd/configure.ac > @@ -227,6 +227,7 @@ AC_CHECK_FUNCS(fcntl fdopen fileno fls getgid getpagesize getrlimit getuid \ > sysconf) > > AC_CHECK_DECLS([basename, ffs, stpcpy, asprintf, vasprintf, strnlen]) > +AC_CHECK_DECLS([___lc_codepage_func], [], [], [[#include ]]) > > BFD_BINARY_FOPEN > > Looks like a much cleaner way to handle the possible absence of the symbol. Thanks for fixing it! Kind regards, Torbjörn