From patchwork Wed Jan 6 18:38:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 1423031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=LFgHX79K; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D9yn001kNz9sVk for ; Thu, 7 Jan 2021 05:38:42 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1BE99384B406; Wed, 6 Jan 2021 18:38:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BE99384B406 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1609958320; bh=bkESMpFQrx9bzpUAvGytYBQlddKdCI0r15kk/Uopsok=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=LFgHX79KrNK0Gh6umbAwNqZwypMxreTiGtDepwa+sZHGxP3xsOcTcw3eDxgZPmUCV BkpQZdyajrfU3k/+IBT2U7zD0bp58Ohpg60jvfUeoiDnH50+akTkkr4oK6tJoKYiiY Fj5SCiHE3tfcAf8+o7Ej6TTUkpBNhsaBhzKfiMPU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 6FDFA384C00B; Wed, 6 Jan 2021 18:38:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6FDFA384C00B Received: by mail-wr1-x42a.google.com with SMTP id 91so3312829wrj.7; Wed, 06 Jan 2021 10:38:37 -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:from:date:message-id:subject:to:cc; bh=bkESMpFQrx9bzpUAvGytYBQlddKdCI0r15kk/Uopsok=; b=C76+TgVgj92cdHer1hKWvNpNS3/0t4i0Cns/I3geVK3doEhOoqbg81OLfGKz6iGIfV izMNiFl2wlGcTEsR8GQ06c8X1DFsFa+mMpPZd6ss7t6PmFAjBonGnwV/QKOpu2xQ/EIe 5CV3vi6nP7B29HOQVzElmvbYDqXjv8GdDQ7dZEJAXBVVR2qWgbOvZfWGUZkTofVBsCde LjqrQqFo9BrG0noOYYiPwCEd7ZzzkyNsoieD98IWMi7o8BY1m+FaJBWqximpzt10bAnz q9KsLpH1wmXVN4dxuVC0KDt9WRXwEbheBJg4GNoeCoHygy7RJo6CKxHhbEkPlAW8t3um IvYg== X-Gm-Message-State: AOAM532dkFO2n/FplIgE3k8JYNzMrm35UUShCvaBMwstzHcvxhkK+5IB zc6LFufxt3AwFV3Fgo4N5EpJmULYPeBtaStlZLg= X-Google-Smtp-Source: ABdhPJyTTYZKqtOCq3XjYc7/yGLO/Nca9aMVPADTWFT8TYXf/28Iz0bM1aAOocm+vGJM7Qun/mi1t1h9nRx1Wsomhls= X-Received: by 2002:a5d:6cc2:: with SMTP id c2mr5467884wrc.374.1609958316587; Wed, 06 Jan 2021 10:38:36 -0800 (PST) MIME-Version: 1.0 Date: Wed, 6 Jan 2021 13:38:25 -0500 Message-ID: Subject: [PATCH, libstdc++] GLIBCXX_HAVE_INT64_T To: Jonathan Wakely X-Spam-Status: No, score=-8.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.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-Patchwork-Original-From: David Edelsohn via Gcc-patches From: David Edelsohn Reply-To: David Edelsohn Cc: Iain Sandoe , libstdc++ , GCC Patches , "CHIGOT, CLEMENT" Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Use __SIZEOF_LONG__ and __SIZEOF_LONG_LONG__ to determine the type of streamoff at compile time instead of _GLIBCXX_HAVE_INT64_T_LONG and _GLIBCXX_HAVE_INT64_T_LONG_LONG. Currently the type of streamoff is determined at libstdc++ configure time, chosen by the definitions of _GLIBCXX_HAVE_INT64_T_LONG and _GLIBCXX_HAVE_INT64_T_LONG_LONG. For a multilib configuration, the difference is encoded in the different multilib header file paths. For "FAT" library targets that package 32 bit and 64 bit libraries together, G++ also expects a single header file directory hierarchy, causing an incorrect value for streamoff in some situations. This patch changes the only use of _GLIBCXX_HAVE_INT64_T_XXX to test __SIZEOF_LONG__ and __SIZEOF__LONG_LONG__ at compile time. Because libstdc++ explicitly probes the type of __int64_t to choose the declaration of streamoff, this patch only performs the dynamic determination if either _GLIBCXX_HAVE_INT64_T_LONG or _GLIBCXX_HAVE_INT64_T_LONG_LONG are defined. In other words, it does assume that if either one is defined, the other is defined, i.e., that __int64_t is a typedef for one of those two types when one or the other is present. But it then dynamically chooses the type based on the size of "long" and "long long" instead of using the configure time value so that the header dynamically adapts to the 32/64 mode of GCC. If neither __GLIBCXX_HAVE_INT64_T_XXX macro is defined, the original logic proceeds, using either __int64_t or "long long". Based on the configure time definitions, the size should be one or the other when one of the macros is defined. I can add an error case if neither __SIZEOF_LONG__ nor __SIZEOF_LONG_LONG__ are 8 despite __GLIBCXX_HAVE_INT64_T_XXX defined. Is this an acceptable solution to determine the value at compile-time? 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