public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
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	[thread overview]
Message-ID: <20230112205949.932013-1-jwakely@redhat.com> (raw)

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<alignof(max_align_t)>(__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<alignof(max_align_t)>(__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;
-- 
2.39.0


                 reply	other threads:[~2023-01-12 20:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230112205949.932013-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).