From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 296691F5A2 for ; Mon, 18 Nov 2019 21:52:48 +0000 (UTC) Received: from localhost ([::1]:39882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWoww-000554-OE for normalperson@yhbt.net; Mon, 18 Nov 2019 16:52:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40241) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWowr-00052I-1v for bug-gnulib@gnu.org; Mon, 18 Nov 2019 16:52:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iWowp-0008Gz-3G for bug-gnulib@gnu.org; Mon, 18 Nov 2019 16:52:40 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::8]:29185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iWowo-0008Fq-Be for bug-gnulib@gnu.org; Mon, 18 Nov 2019 16:52:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1574113954; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=CaQE3P/TC7pY4c+FYsO8kS8YjIZ+VWxzeQCXAVJZrUY=; b=OG8l3H4DXtHZlJlAd6LvtkJv58xcHrfF4c7k87YZk6L6DeEyDWmYF2D4R5JP2UTD/Z 8IHBW+ZHkV9DCBOd/jnTEPGJ95JDnOGES90lZ8nmNreGdyR3EPAc22+v+WRNcMgoBpZ+ 0oBpQD9rgZH0LWz2Zl5hSs4Q9/EyZrym451gdJeb6kDHkHBu6sB89Z57+Yrg4RmQ226m Fqc2/cRQiIXX0/ei3o9maWBImQMgD0Kyfe97zqV+epxlgOhXD0bAGGzGc0w5vBYMf80d CD5Su1cLsgloQEvnvxhmsIRaM87HpJQ/dv4dpgd1F87IWpGTK6Hs8S8X6bndc/q0bx5z N1dQ== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 44.29.0 DYNA|AUTH) with ESMTPSA id g09d55vAILqK1la (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Mon, 18 Nov 2019 22:52:20 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: gnulib subverts system typedef for intptr_t Date: Mon, 18 Nov 2019 22:52:19 +0100 Message-ID: <2978907.HnveO5ds4X@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <2613685.cZcoHrbQqH@omega> References: <6162c57f-f9d0-936a-fd3a-20d19b507286@users.osdn.me> <2613685.cZcoHrbQqH@omega> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart5625102.h6ErvMOiqy" Content-Transfer-Encoding: 7Bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::8 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Marshall Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This is a multi-part message in MIME format. --nextPart5625102.h6ErvMOiqy Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hi Keith, > > I ran into this, when cross-compiling GNU gettext-0.20.1 for a mingw32 > > host; you may find details at > > > > https://osdn.net/projects/mingw/ticket/39677 > > > > While I can work around the compilation failure, (and the workaround > > likely makes the MinGW.org headers more robust), I thought you may like > > to know of the underlying issue. With earlier versions of mingw, the configure test checking whether stdint.h conforms to C99... reports 'yes', then gnulib does not redefined intptr_t, then the declaration conflict of '_findclose' would not arise. In other words, the issue you observed is triggered by the fact that the mingw headers that you are using do not contain a good any more. You can find out what is wrong by looking into config.log. Now, when I put myself into the same situation, by setting the environment variable $ export gl_cv_header_working_stdint_h=no I encounter two test failures in . The first issue is that WINT_MAX is incorrectly defined: it is defined as _STDINT_MAX(0, 32, 0) but ought to be defined as _STDINT_MAX(0, 32, 0u) The second issue is that intptr_t and uintptr_t are 32-bit, whereas pointers in 64-bit native Windows are 64-bit. I'm committing the fixes for these two failures (attached). 2019-11-18 Bruno Haible stdint: Fix value of WINT_MAX when we override wint_t. * lib/stdint.in.h (WINT_MIN, WINT_MAX): Don't override a second time when GNULIB_OVERRIDES_WINT_T is 1. 2019-11-18 Bruno Haible stdint: Define [u]intptr_t correctly on 64-bit native Windows. * lib/stdint.in.h (gl_intptr_t, gl_uintptr_t, INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX): Consider _WIN64. * tests/test-stdint.c: Verify that [u]intptr_t is large enough to hold a pointer. --nextPart5625102.h6ErvMOiqy Content-Disposition: attachment; filename="0001-stdint-Fix-value-of-WINT_MAX-when-we-override-wint_t.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-stdint-Fix-value-of-WINT_MAX-when-we-override-wint_t.patch" >From ee1eac82e997ff1b7c8524af74a461b4822c91df Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 18 Nov 2019 22:40:36 +0100 Subject: [PATCH 1/2] stdint: Fix value of WINT_MAX when we override wint_t. * lib/stdint.in.h (WINT_MIN, WINT_MAX): Don't override a second time when GNULIB_OVERRIDES_WINT_T is 1. --- ChangeLog | 6 ++++++ lib/stdint.in.h | 24 ++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 048335a..803dcd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2019-11-18 Bruno Haible + stdint: Fix value of WINT_MAX when we override wint_t. + * lib/stdint.in.h (WINT_MIN, WINT_MAX): Don't override a second time + when GNULIB_OVERRIDES_WINT_T is 1. + +2019-11-18 Bruno Haible + vcs-to-changelog: New module. * modules/vcs-to-changelog: New file. * MODULES.html.sh (func_all_modules): Add it. diff --git a/lib/stdint.in.h b/lib/stdint.in.h index 733fcb3..e965c4a 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -591,17 +591,21 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) /* wint_t limits */ -# undef WINT_MIN -# undef WINT_MAX -# if @HAVE_SIGNED_WINT_T@ -# define WINT_MIN \ - _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) -# else -# define WINT_MIN \ - _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +/* If gnulib's or overrides wint_t, @WINT_T_SUFFIX@ is not + accurate, therefore use the definitions from above. */ +# if !@GNULIB_OVERRIDES_WINT_T@ +# undef WINT_MIN +# undef WINT_MAX +# if @HAVE_SIGNED_WINT_T@ +# define WINT_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# else +# define WINT_MIN \ + _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# endif +# define WINT_MAX \ + _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) # endif -# define WINT_MAX \ - _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) /* 7.18.4. Macros for integer constants */ -- 2.7.4 --nextPart5625102.h6ErvMOiqy Content-Disposition: attachment; filename="0002-stdint-Define-u-intptr_t-correctly-on-64-bit-native-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0002-stdint-Define-u-intptr_t-correctly-on-64-bit-native-.patch" >From 3701658a6ae874972a7e41e1e9632782f84534d6 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 18 Nov 2019 22:41:09 +0100 Subject: [PATCH 2/2] stdint: Define [u]intptr_t correctly on 64-bit native Windows. * lib/stdint.in.h (gl_intptr_t, gl_uintptr_t, INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX): Consider _WIN64. * tests/test-stdint.c: Verify that [u]intptr_t is large enough to hold a pointer. --- ChangeLog | 8 ++++++++ lib/stdint.in.h | 25 ++++++++++++++++++------- tests/test-stdint.c | 2 ++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 803dcd1..5c8eed1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2019-11-18 Bruno Haible + stdint: Define [u]intptr_t correctly on 64-bit native Windows. + * lib/stdint.in.h (gl_intptr_t, gl_uintptr_t, INTPTR_MIN, INTPTR_MAX, + UINTPTR_MAX): Consider _WIN64. + * tests/test-stdint.c: Verify that [u]intptr_t is large enough to hold + a pointer. + +2019-11-18 Bruno Haible + stdint: Fix value of WINT_MAX when we override wint_t. * lib/stdint.in.h (WINT_MIN, WINT_MAX): Don't override a second time when GNULIB_OVERRIDES_WINT_T is 1. diff --git a/lib/stdint.in.h b/lib/stdint.in.h index e965c4a..37c15fc 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -308,12 +308,17 @@ typedef gl_uint_fast32_t gl_uint_fast16_t; _findclose in . */ # if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \ || (defined __MINGW32__ && defined _INTPTR_T_DEFINED && defined _UINTPTR_T_DEFINED)) -# undef intptr_t -# undef uintptr_t +# undef intptr_t +# undef uintptr_t +# ifdef _WIN64 +typedef long long int gl_intptr_t; +typedef unsigned long long int gl_uintptr_t; +# else typedef long int gl_intptr_t; typedef unsigned long int gl_uintptr_t; -# define intptr_t gl_intptr_t -# define uintptr_t gl_uintptr_t +# endif +# define intptr_t gl_intptr_t +# define uintptr_t gl_uintptr_t # endif /* 7.18.1.5. Greatest-width integer types */ @@ -490,9 +495,15 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) # undef INTPTR_MIN # undef INTPTR_MAX # undef UINTPTR_MAX -# define INTPTR_MIN LONG_MIN -# define INTPTR_MAX LONG_MAX -# define UINTPTR_MAX ULONG_MAX +# ifdef _WIN64 +# define INTPTR_MIN LLONG_MIN +# define INTPTR_MAX LLONG_MAX +# define UINTPTR_MAX ULLONG_MAX +# else +# define INTPTR_MIN LONG_MIN +# define INTPTR_MAX LONG_MAX +# define UINTPTR_MAX ULONG_MAX +# endif /* 7.18.2.5. Limits of greatest-width integer types */ diff --git a/tests/test-stdint.c b/tests/test-stdint.c index a87830b..057d5e3 100644 --- a/tests/test-stdint.c +++ b/tests/test-stdint.c @@ -217,12 +217,14 @@ err or; /* 7.18.2.4. Limits of integer types capable of holding object pointers */ intptr_t g[3] = { 17, INTPTR_MIN, INTPTR_MAX }; +verify (sizeof (void *) <= sizeof (intptr_t)); verify (TYPE_MINIMUM (intptr_t) == INTPTR_MIN); verify (TYPE_MAXIMUM (intptr_t) == INTPTR_MAX); verify_same_types (INTPTR_MIN, (intptr_t) 0 + 0); verify_same_types (INTPTR_MAX, (intptr_t) 0 + 0); uintptr_t h[2] = { 17, UINTPTR_MAX }; +verify (sizeof (void *) <= sizeof (uintptr_t)); verify (TYPE_MAXIMUM (uintptr_t) == UINTPTR_MAX); verify_same_types (UINTPTR_MAX, (uintptr_t) 0 + 0); -- 2.7.4 --nextPart5625102.h6ErvMOiqy--