From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 008A838432E4; Thu, 12 Jan 2023 20:59:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 008A838432E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673557173; bh=YH3WjAdbaTuDOg/pSjKFiHnh6IJnIITvPnkILcjpAek=; h=From:To:Subject:Date:From; b=szEpoQBw4SqUXFOGgRDOeBLw3FjRghNbP8OItQ6f9fX7uSOc8C6Cg1Os72xMNcbWc iqOBoR8CMl7dfFm9jbNA2Q3yMggkU1+xwcC92gBausCasQg4KQKowmlFEpB0/2e2cx BoKVcOPOFo/KKHXnW1Xeiq7+B2ze7ilfUzNutwgY= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-5127] libstdc++: Extend max_align_t special case to 64-bit HP-UX [PR77691] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: ac1c7fcce1f57ba83cfe868f82f8c9eb776ddc32 X-Git-Newrev: f629f63d2d9d7ad2c43f8e451f0f6e32b5f4d06a Message-Id: <20230112205933.008A838432E4@sourceware.org> Date: Thu, 12 Jan 2023 20:59:32 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f629f63d2d9d7ad2c43f8e451f0f6e32b5f4d06a commit r13-5127-gf629f63d2d9d7ad2c43f8e451f0f6e32b5f4d06a Author: Jonathan Wakely Date: Thu Jan 12 10:58:13 2023 +0000 libstdc++: Extend max_align_t special case to 64-bit HP-UX [PR77691] 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. Diff: --- libstdc++-v3/include/experimental/memory_resource | 15 ++++++++++++--- .../experimental/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;