From patchwork Tue Oct 4 14:11:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp149243wrs; Tue, 4 Oct 2022 07:14:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6EOwHoeJODDGEsCCII2+6jUE4ybGm/ylSklAhWNqRwcv2ohzMjCsoiXxMxojBgU6cDA0pY X-Received: by 2002:a05:6402:28a1:b0:458:81c0:a379 with SMTP id eg33-20020a05640228a100b0045881c0a379mr18559166edb.388.1664892858020; Tue, 04 Oct 2022 07:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664892858; cv=none; d=google.com; s=arc-20160816; b=WC3YCDtjl8QdTQuZYRu4XFmusnd1+azPiY8IiYoNu9hWaIfrXRBsjkMuOuVgIEIHw+ 3LK1Z1QpVgipuTybwcXpOR1/Wx7YRYWRkuAL16AFDJc8/Rm1WEy/8+gpQOG9dvJN6a9W OQrxIYfCoyCAgb8XfyyJdyS9NG6UZIlnVlNOjXL4MDrRfHedndoUqXe8PNol2b1r620S qoTRXv+nIfmF/w/xgNoqQpBxXPxxKFlkW3P+zd8rua7AsPsWk1QI9Lx6Z4tPJ/fDnwEC nZgMqIAhZmMEwz8y7Vna2e7uFCF6oNeoZUqtwyaM/aB71yu1T04d4C2csZkes1d1Gpok 3X3w== 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-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Xyx0mtP5ZBGUCMdiMXzywdLNxHBIL6+YrBx2sEye3tM=; b=0x18mxJs8MdiOIc9EHih6+NvdUKkrFEuPCe4dJHM1PNb4HAWKqHGBYfjZzMi7owNnk Oy1wxoeUtOOkH+qeItNbbiw0mFX5gzmwif3uLt0mM4XGoCCcLk0bx4v1dxyoL1KBSWx9 wVCSsH9bZzhZVZGNA3vDeCUGVDtWIjvRemnWkTN8W0zvPeX4ysds7pnFzgBqbiaaWM0n iS0Jjch4aBPxPJF9k8JSyhHnTWNNkdk+ObmeDBblJJttHOiBNHG5lKbmIfGuvn/wpKoX dGTWyXAjefX7DaNZf0GLB424AeRvG8z0bbYiaF3rLJ+n84rfr9YVJWhnnjpNU8Gu0F8B Up6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GdAY7dQs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gn17-20020a1709070d1100b00781e6ba9528si10820933ejc.133.2022.10.04.07.14.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 07:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.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=@gcc.gnu.org header.s=default header.b=GdAY7dQs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A6F93860770 for ; Tue, 4 Oct 2022 14:13:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A6F93860770 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664892784; bh=Xyx0mtP5ZBGUCMdiMXzywdLNxHBIL6+YrBx2sEye3tM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GdAY7dQsJO1uLAVv7ZfwcVsUEJIzgVqJTFb6fXibKWIArC3MYMdSbja+aOj2CMX6+ USnvRwsyv5yg5xvOXBc4zk2ZpWSJYVod46X9T2otgzPyEU0ASLcbzcSFhFfzFIjJpO 8uwWbGc1Aa7rCyBpbMOZmu/i0uf47IVfRMEVpemA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B57383858C39 for ; Tue, 4 Oct 2022 14:11:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B57383858C39 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-vXTcKWu8O4ykLgFbJT5IIg-1; Tue, 04 Oct 2022 10:11:41 -0400 X-MC-Unique: vXTcKWu8O4ykLgFbJT5IIg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F461882823; Tue, 4 Oct 2022 14:11:40 +0000 (UTC) Received: from localhost (unknown [10.33.36.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48027492B04; Tue, 4 Oct 2022 14:11:40 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Make work freestanding [PR107134] Date: Tue, 4 Oct 2022 15:11:36 +0100 Message-Id: <20221004141138.530214-2-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745766693657002656?= X-GMAIL-MSGID: =?utf-8?q?1745766693657002656?= Tested powerpc64le-linux, and x86_64-linux with -ffreestanding. Pushed to trunk. -- >8 -- When gcc/config.gcc defines use_gcc_stdin=wrap, GCC's tries to use libc's unless -ffreestanding is used. When libstdc++ is configured --disable-hosted-libstdcxx we want to work even without -ffreestanding being given. This is a kluge to make it include GCC's directly even without -ffreestanding. libstdc++-v3/ChangeLog: PR libstdc++/107134 * include/c_global/cstdint [!_GLIBCXX_HOSTED]: Include directly. --- libstdc++-v3/include/c_global/cstdint | 59 ++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/c_global/cstdint b/libstdc++-v3/include/c_global/cstdint index 4490d06f099..4b9df45a9ee 100644 --- a/libstdc++-v3/include/c_global/cstdint +++ b/libstdc++-v3/include/c_global/cstdint @@ -37,7 +37,11 @@ #include -#if _GLIBCXX_HAVE_STDINT_H +#if ! _GLIBCXX_HOSTED && __has_include() +// For --disable-hosted-libstdcxx we want GCC's own stdint-gcc.h header +// even when -ffreestanding isn't used. +# include +#elif __has_include() # include #endif @@ -80,9 +84,60 @@ namespace std using ::uintmax_t; using ::uintptr_t; #else // !_GLIBCXX_USE_C99_STDINT_TR1 - // Define the minimum needed for , etc. + using intmax_t = __INTMAX_TYPE__; using uintmax_t = __UINTMAX_TYPE__; + +#ifdef __INT8_TYPE__ + using int8_t = __INT8_TYPE__; +#endif +#ifdef __INT16_TYPE__ + using int16_t = __INT16_TYPE__; +#endif +#ifdef __INT32_TYPE__ + using int32_t = __INT32_TYPE__; +#endif +#ifdef __INT64_TYPE__ + using int64_t = __INT64_TYPE__; +#endif + + using int_least8_t = __INT_LEAST8_TYPE__; + using int_least16_t = __INT_LEAST16_TYPE__; + using int_least32_t = __INT_LEAST32_TYPE__; + using int_least64_t = __INT_LEAST64_TYPE__; + using int_fast8_t = __INT_FAST8_TYPE__; + using int_fast16_t = __INT_FAST16_TYPE__; + using int_fast32_t = __INT_FAST32_TYPE__; + using int_fast64_t = __INT_FAST64_TYPE__; + +#ifdef __INTPTR_TYPE__ + using intptr_t = __INTPTR_TYPE__; +#endif + +#ifdef __UINT8_TYPE__ + using uint8_t = __UINT8_TYPE__; +#endif +#ifdef __UINT16_TYPE__ + using uint16_t = __UINT16_TYPE__; +#endif +#ifdef __UINT32_TYPE__ + using uint32_t = __UINT32_TYPE__; +#endif +#ifdef __UINT64_TYPE__ + using uint64_t = __UINT64_TYPE__; +#endif + using uint_least8_t = __UINT_LEAST8_TYPE__; + using uint_least16_t = __UINT_LEAST16_TYPE__; + using uint_least32_t = __UINT_LEAST32_TYPE__; + using uint_least64_t = __UINT_LEAST64_TYPE__; + using uint_fast8_t = __UINT_FAST8_TYPE__; + using uint_fast16_t = __UINT_FAST16_TYPE__; + using uint_fast32_t = __UINT_FAST32_TYPE__; + using uint_fast64_t = __UINT_FAST64_TYPE__; +#ifdef __UINTPTR_TYPE__ + using uintptr_t = __UINTPTR_TYPE__; +#endif + #endif // _GLIBCXX_USE_C99_STDINT_TR1 } // namespace std