From patchwork Thu Jan 12 20:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 42809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4102687wrt; Thu, 12 Jan 2023 13:01:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXvGeOi4H4sXSA7X7KZAP0ZwKDVrGMaT7xVg4j+wUs0xnSPbqS141ogD6XyA7knD4innIGhs X-Received: by 2002:a17:907:7da4:b0:78d:f455:b5dc with SMTP id oz36-20020a1709077da400b0078df455b5dcmr82792024ejc.28.1673557281948; Thu, 12 Jan 2023 13:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673557281; cv=none; d=google.com; s=arc-20160816; b=iq9l3uhWlNQ7kOUt8xsHDScVMnBme7+TIGn6QuZvwkCxu+V7hRx7+Kv0BnbTT5lVe6 0k8eeTgAaweYCmSj4PpBVun2VKtQ4bsdxEUjJFkFEDeg2WRsH9jS2gd9eDEr0pEbw2av mNdgdhFS2SO4ya7l7OWCWHAtUFi/5a2ce3g7MmgcDU20R5PWTWp0/q+e6tXlS399D4FB 5m8IXUmuFRb9NqXNDuPw3CmgDwtBlPaBCUtOUWBcKUgMassTFdeKMeaSung5Ja7uwuZp CdN7TOc7qm0+C31NUitmRn5HqRbY3P+gi3KELWmlYib4PzIlnRtd32mPR3l6J4xhSVer rEhg== 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=tQovNiJ2rywMJP0ufBq8ICl4uu1jgHsB1N5YbXvWoCc=; b=cbzBGHAKUJG5kzWlEIb7cnWOJnMYyVCzfpdjXXITiSYK3FQ6eUjB4QY9yz3Z07CzDp erghnNDbxlQGpKYJiSi4uqTp5Y3i36R1dQ0NhJx9m9eJOA6PkI0GNKdtAvhBfSYVcdPA GzkE4wrBcuTzI92ip/X+BPmVA0zCXd6Hdte2ECMkxFaV0+OANvZ1/qREzJqhJ0qIi4Mf QANajwO0DlIKEMQDbv/6mUmeDTJMu2wnpXo7iOGs1JVVns+sUiqF5J8JMgh6DoPxjIr/ NwLv7NQctt8fFmvwTrj77Xfyi5IuFZJd8OYCtBuxWRBTJaZ3oMgb/dGyoeJLtcSRpj4T 8s+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ygXjGYMU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id un2-20020a170907cb8200b007adadfc97c7si15504741ejc.918.2023.01.12.13.01.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 13:01:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ygXjGYMU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 4B941385439C for ; Thu, 12 Jan 2023 21:00:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B941385439C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673557235; bh=tQovNiJ2rywMJP0ufBq8ICl4uu1jgHsB1N5YbXvWoCc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ygXjGYMUbe/rWSdZK1GDSHIvgLuH9e/gWZnRd2TwCP6NFVWbBANp1dQnYELwlvX7c tJ9PgbM9g11SyRsTrdKfq2IiQLDF092RznAphR7n07xUA0Nd4TgX+TTwd2Sz8EAh/t pE22jMYOcP4iPzBk686xiIYbmHgpWxupjT2W+CcM= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 49C453841446 for ; Thu, 12 Jan 2023 20:59:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49C453841446 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-286-Gf8l3VEfNw-ANPD4sycEqg-1; Thu, 12 Jan 2023 15:59:50 -0500 X-MC-Unique: Gf8l3VEfNw-ANPD4sycEqg-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 4A9DC85D061; Thu, 12 Jan 2023 20:59:50 +0000 (UTC) Received: from localhost (unknown [10.33.36.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14A04492B00; Thu, 12 Jan 2023 20:59:49 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Extend max_align_t special case to 64-bit HP-UX [PR77691] Date: Thu, 12 Jan 2023 20:59:49 +0000 Message-Id: <20230112205949.932013-1-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=-11.8 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 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?1754852000513722684?= X-GMAIL-MSGID: =?utf-8?q?1754852000513722684?= Tested x86_64-linux. Pushed to trunk. -- >8 -- GCC's std::max_align_t doesn't agree with the system malloc on HP-UX, so generalize the current hack for Solaris to apply to that target too. libstdc++-v3/ChangeLog: PR libstdc++/77691 * include/experimental/memory_resource (_GLIBCXX_MAX_ALIGN_MATCHES_MALLOC): Define. (do_allocate, do_deallocate): Check it. * testsuite/experimental/memory_resource/new_delete_resource.cc: Relax expected behaviour for 64-bit hppa-hp-hpux11.11. --- libstdc++-v3/include/experimental/memory_resource | 15 ++++++++++++--- .../memory_resource/new_delete_resource.cc | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/experimental/memory_resource b/libstdc++-v3/include/experimental/memory_resource index aa86c042d84..786392e8904 100644 --- a/libstdc++-v3/include/experimental/memory_resource +++ b/libstdc++-v3/include/experimental/memory_resource @@ -412,11 +412,20 @@ namespace pmr { allocator_type get_allocator() const noexcept { return _M_alloc; } protected: +#if (defined __sun__ || defined __VXWORKS__) && defined __i386__ +// Cannot use max_align_t on 32-bit Solaris x86, see PR libstdc++/77691 +# define _GLIBCXX_MAX_ALIGN_MATCHES_MALLOC 0 +#elif defined __hpux__ && defined __hppa__ && defined __LP64__ +// Ignore inconsistent long double and malloc alignment (libstdc++/77691) +# define _GLIBCXX_MAX_ALIGN_MATCHES_MALLOC 0 +#else +# define _GLIBCXX_MAX_ALIGN_MATCHES_MALLOC 1 +#endif + virtual void* do_allocate(size_t __bytes, size_t __alignment) override { - // Cannot use max_align_t on 32-bit Solaris x86, see PR libstdc++/77691 -#if ! ((defined __sun__ || defined __VXWORKS__) && defined __i386__) +#if _GLIBCXX_MAX_ALIGN_MATCHES_MALLOC if (__alignment == alignof(max_align_t)) return _M_allocate(__bytes); #endif @@ -442,7 +451,7 @@ namespace pmr { do_deallocate(void* __ptr, size_t __bytes, size_t __alignment) noexcept override { -#if ! ((defined __sun__ || defined __VXWORKS__) && defined __i386__) +#if _GLIBCXX_MAX_ALIGN_MATCHES_MALLOC if (__alignment == alignof(max_align_t)) return (void) _M_deallocate(__ptr, __bytes); #endif diff --git a/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc b/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc index d121d5f2c41..a7ecb54b905 100644 --- a/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc +++ b/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc @@ -27,6 +27,10 @@ // See PR libstdc++/77691 # define BAD_MAX_ALIGN_T 1 #endif +#if defined __hpux__ && defined __hppa__ && defined __LP64__ +// Ignore inconsistent long double and malloc alignment (libstdc++/77691) +# define BAD_MAX_ALIGN_T 1 +#endif bool new_called = false; bool delete_called = false;