From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102a.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso15819514pjt.0 for ; Tue, 20 Dec 2022 00:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=DEoBRa2WkOnKrgtd4zQViUnyx0vjowVWHwKQpLX01pw=; b=EdsB0dOz71brytLEo8Ugu6GBJGQcGlRlwqEdGZO+ewdmtvI9LTwGJkZ4TLa+OkRn4N ji0ZFyrcWR6yEw4qOLZoI7MFLnv7NaXMLp4P6PCY+LfD/7GF5TZ1qos3HYEi2okGqw4t 9U7m+1FLSKllqjqu+FfE15yob+47PT8VwAWD2LbP/rZVl0ry/okngtdSVLHxYhXZSOII 4xQWMyX9H/2lJxMLE5FZ8g01hcHdyZVB1YIPKE1XRXyI6MPbVZu0Ftd7KLhdH1YrtCTZ J28D3IRdGS+VY+Nf3jdGjDM0lWp4H7//vi8QSFWjShABnwP5vI8wvkuAaKjktE8fqOOV lVvA== 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-Google-Smtp-Source: AA0mqf7y33aiqHgJt62htKlqTXFPP04KBUzI407W+MZ/CsDR0DqjDt/20oIq/FGTBa8xpaLfqqyvyg== 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 From: Alan Modra 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-Type: text/plain; charset=us-ascii 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 List-Id: 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 -- Alan Modra Australia Development Lab, IBM