From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 5CA463846070; Wed, 6 Jan 2021 21:20:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5CA463846070 Received: by mail-wr1-x42f.google.com with SMTP id r7so3668428wrc.5; Wed, 06 Jan 2021 13:20:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0Bzf46kikE08GdTeIIfIK446wtOTQGEswxgvhRA34i0=; b=VMwwwcWTqNEYRbhC8jDNeshCItBsaO66HfLkMkHJgryOTL/SdsHKtEYVunazYixGqp v7xb1WVt8w1sJGjOo42xIphOauc+nQMBw6uJn1wo1YSDuQiqJZoiYxKlb2C7xgp2aZHa +QHOK//rtU5gHN+94E7C3Y0ihrVooFa2er5MPKUh6NZv67MlIXp6FBkB49PutyslYW1+ X6D8yuGzsN/ImD2yK75HU0fUVfgBDhvw1rd9A9WC6q0OkO+qWNlLMjEGJseeu/eUBeF1 As0fKxTkNmwbZSLmhJCvMpXnbb7y0uXAP3XPXRXxbfsUl/rz0N55rAQdMESZ2tsrXKSm j3KA== X-Gm-Message-State: AOAM5323IWMwTuYuK/DGT1lfzUPYhhfcI2lvN7cYVo1Cq7Sny95uy4rh 5YksDaJa8+jNilIhBDWfi8UZ09XkLcP3HWxbn/M= X-Google-Smtp-Source: ABdhPJy3XQImczBZ6gHtL505HPRIVjx3+nuoTBmyG7eT3qEoSTmg6wqlbwIwtZUAEzqMfpMukXjdqNmnM8asirjxk0Q= X-Received: by 2002:adf:e98b:: with SMTP id h11mr5882836wrm.21.1609968034485; Wed, 06 Jan 2021 13:20:34 -0800 (PST) MIME-Version: 1.0 References: <20210106193746.GD725145@tucnak> In-Reply-To: <20210106193746.GD725145@tucnak> From: David Edelsohn Date: Wed, 6 Jan 2021 16:20:22 -0500 Message-ID: Subject: Re: [PATCH, libstdc++] GLIBCXX_HAVE_INT64_T To: Jakub Jelinek Cc: Jonathan Wakely , Iain Sandoe , "libstdc++" , GCC Patches , "CHIGOT, CLEMENT" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jan 2021 21:20:36 -0000 On Wed, Jan 6, 2021 at 2:37 PM Jakub Jelinek wrote: > > On Wed, Jan 06, 2021 at 01:38:25PM -0500, David Edelsohn via Gcc-patches wrote: > > Is this an acceptable solution to determine the value at compile-time? > > This looks wrong to me. The fact that long is 64-bit doesn't imply that > int64_t as defined by stdint.h must be long, it could be long long too. > And while e.g. for C it doesn't really matter much whether streamoff > will be long or long long if those two have the same precision, > for C++ it matters a lot (affects mangling etc.). Your response doesn't correspond to the patch nor to what I described. Nowhere did I say that int64_t must correspond to "long". The patch specifically chooses "long" or "long long" based on the __SIZEOF_LONG__ *and* __SIZEOF_LONG_LONG__. Currently libstdc++ configure tests for the type at configuration time. My patch changes the behavior to retain the test for the type at configure time but chooses "long" or "long long" at compile time. I don't unilaterally choose "long" or "long long" as the type, but rely on the configure test to ensure that __int64_t is a typedef for either "long" or "long long". The patch does assume that if __int64_t is a typedef for "long" or "long long" and this is a 32/64 multilib, then the typedef for the other 32/64 mode is an equivalent typedef, which is the case for GLIBC, AIX, and other systems that I have checked. Thanks, David > > > diff --git a/libstdc++-v3/include/bits/postypes.h > > b/libstdc++-v3/include/bits/postypes.h > > index cb44cfe1396..81b9c4c6ae5 100644 > > --- a/libstdc++-v3/include/bits/postypes.h > > +++ b/libstdc++-v3/include/bits/postypes.h > > @@ -84,10 +84,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > * Note: In versions of GCC up to and including GCC 3.3, streamoff > > * was typedef long. > > */ > > -#ifdef _GLIBCXX_HAVE_INT64_T_LONG > > +#if defined(_GLIBCXX_HAVE_INT64_T_LONG) \ > > + || defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG) > > + > > +#if __SIZEOF_LONG__ == 8 > > typedef long streamoff; > > -#elif defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG) > > +#elif __SIZEOF_LONG_LONG__ == 8 > > typedef long long streamoff; > > +#endif > > + > > #elif defined(_GLIBCXX_HAVE_INT64_T) > > typedef int64_t streamoff; > > #else > > Jakub >