Commit 84c08ec9 by Jonathan Wakely Committed by Jonathan Wakely

Replace modulus with mask operation in over-aligned new

2016-09-16  Jonathan Wakely  <jwakely@redhat.com>
	    Marc Glisse  <marc.glisse@inria.fr>

	* libsupc++/new_opa.cc [_GLIBCXX_HAVE_ALIGNED_ALLOC]
	(operator new(size_t, align_val_t)): Replace modulus operator with
	mask.

Co-Authored-By: Marc Glisse <marc.glisse@inria.fr>

From-SVN: r240192
parent 8d987deb
2016-09-16 Jonathan Wakely <jwakely@redhat.com> 2016-09-16 Jonathan Wakely <jwakely@redhat.com>
Marc Glisse <marc.glisse@inria.fr>
* libsupc++/new_opa.cc [_GLIBCXX_HAVE_ALIGNED_ALLOC]
(operator new(size_t, align_val_t)): Replace modulus operator with
mask.
2016-09-16 Jonathan Wakely <jwakely@redhat.com>
* libsupc++/new_opa.cc [_GLIBCXX_HAVE_POSIX_MEMALIGN] (aligned_alloc): * libsupc++/new_opa.cc [_GLIBCXX_HAVE_POSIX_MEMALIGN] (aligned_alloc):
Increase alignment if less than sizeof(void*). Increase alignment if less than sizeof(void*).
......
...@@ -69,7 +69,7 @@ operator new (std::size_t sz, std::align_val_t al) ...@@ -69,7 +69,7 @@ operator new (std::size_t sz, std::align_val_t al)
#if _GLIBCXX_HAVE_ALIGNED_ALLOC #if _GLIBCXX_HAVE_ALIGNED_ALLOC
/* C11: the value of size shall be an integral multiple of alignment. */ /* C11: the value of size shall be an integral multiple of alignment. */
if (std::size_t rem = sz % align) if (std::size_t rem = sz & (align - 1))
sz += align - rem; sz += align - rem;
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment