From patchwork Tue Dec 20 08:34:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 34990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2844330wrn; Tue, 20 Dec 2022 00:34:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXv+4MYkW+btmVp0a1XnajemY6+9YACybTI6IBMi3/kGgJgJm/soGyMMCfDnZffdGX/kzGwA X-Received: by 2002:a17:907:9b04:b0:7c0:8578:f4c0 with SMTP id kn4-20020a1709079b0400b007c08578f4c0mr19637076ejc.67.1671525285655; Tue, 20 Dec 2022 00:34:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671525285; cv=none; d=google.com; s=arc-20160816; b=armJasjFEilY4ssFlcWhNBxGmj1nfA/r+ahLDQiGAv1nUaQZyGnsKcilzjEuBgEQJO ybx4Go45hpOdkx+qV2l1zhfLPrnO1HOMpWFVLb6i2Wbg6WwaveBqSykev+4mC0WiicQo sEdl5Xf06SU1zZe6pgkqlUi7hm3WlhyuuNfNQ0XPZRqLm8ekNDe6A7YOdzDitkl26h8j hv+3S3Cwexzh/v/bDseuQ0LbvnQS9a4PiWFGI4gPPLW61nZYdL301ZQ7HRhIp0hIUhzD SNQj7081eeTwud/UQyd++BZyswHrKeuRvsEFdianTs761/EyKK95CBbhBvui4nD/AwSL +RDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=DEoBRa2WkOnKrgtd4zQViUnyx0vjowVWHwKQpLX01pw=; b=KZQ8FMvCR7Hpyc7gT5pAeCq37WYpZwPCUd/lDybynpTVAVrXKjLI1lZglUwg1h6MQ+ seWcrrnwivYXxQWpxV2hMtZt7vMikHVcDtIGg1P5gt4JveiZhj6mNUPyObmwGiTU9Crp Zc6DCGwOSawVDxqH6cp1JV4uLY0PaDsiBzPZV/aiH7VHLi/MbuFTkcyAEarwdaxmKE/c YXq55rAuqt2BvD+pqLBoMthJYsE1Z/pNLn/809TagJAssR7Gng8SxAcGvze2p2cXwrIc zahYwJpB0K1PuqWBpJbKlA16O2BkYXhxoNnQYK77GwhHrQpL5HJyVQc4mKITGG4JTk4R kpzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=LkZUjYt+; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i13-20020a1709064fcd00b00780488c11bbsi12054965ejw.388.2022.12.20.00.34.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 00:34:45 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=LkZUjYt+; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 72AC33858C39 for ; Tue, 20 Dec 2022 08:34:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72AC33858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671525284; bh=DEoBRa2WkOnKrgtd4zQViUnyx0vjowVWHwKQpLX01pw=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=LkZUjYt+vL9/nRu4Ex/AcuYjF6q33Q/QdGRsP/HdWviZ4luj/XIXTmTe9y0RV+X1k /+ZgTydS6wNVYZOPVpK71EbyI01qTloa1qmOWNdGQ1kl7G/rBLTsvYqiggDiMCUzlr /peVkAuWMAbcgjvphjTznGDIg6vN8q8aYgrPBUpc= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 882553858408 for ; Tue, 20 Dec 2022 08:34:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 882553858408 Received: by mail-pj1-x102a.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso15819514pjt.0 for ; Tue, 20 Dec 2022 00:34:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DEoBRa2WkOnKrgtd4zQViUnyx0vjowVWHwKQpLX01pw=; b=lv3bKRlldZPc/qUcK8KfuuaPHcHqjgnR0WCUPCCdG1OnHKaGfb0Wm3pgGtpCaoh+1q gaMaoVh6fjnftKlA0V6FCg+ED05rhhDPKN8htuveP2IizivftkAngRjlfGmdXc4EUfbC Zmex8FsZGzyUv4NynD54dPBHh2CcV5w3ILvPd7P7Et8R9MTp13IBstuWiOtLo7EbldsR w5JzhQyu6VgT1DciJAOpurz1CinA5QqosEL5EJk9/L+WSpxCNyxFv4zw6I+y0pKLVIjM WdqNEfEnUoc3ctiUFvLgiTysfYItVeNnOW4u5RP6tEjEB3Qqf/PrlxEsaRE3IElk7VXP 9B/w== X-Gm-Message-State: ANoB5pkGq7QrjlAfE1wmg1Az5jpasiufBO0gohQT/bgndSwiIRs3qAUv GEW1ORb6dAweyvv347Jnrb/3fGr8lcY= X-Received: by 2002:a17:902:d58f:b0:189:8141:e827 with SMTP id k15-20020a170902d58f00b001898141e827mr48266873plh.56.1671525270576; Tue, 20 Dec 2022 00:34:30 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:134e:568b:f710:ec7]) by smtp.gmail.com with ESMTPSA id i3-20020a631303000000b00478fbfd5276sm7633045pgl.15.2022.12.20.00.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 00:34:30 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 3D0851142D99; Tue, 20 Dec 2022 19:04:28 +1030 (ACDT) Date: Tue, 20 Dec 2022 19:04:28 +1030 To: binutils@sourceware.org Cc: torbjorn.svensson@foss.st.com Subject: PR29915, bfdio.c does not compile with mingw.org's MinGW Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752721297990749552?= X-GMAIL-MSGID: =?utf-8?q?1752721297990749552?= 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