From: Jonathan Wakely Date: Fri, 16 Sep 2016 18:09:14 +0000 (+0100) Subject: Replace modulus with mask operation in over-aligned new X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84c08ec96a558fcb648e27f3f4a2e7532079d5bd;p=gcc.git Replace modulus with mask operation in over-aligned new 2016-09-16 Jonathan Wakely Marc Glisse * 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 From-SVN: r240192 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index cddff99466d..21ee3fd70f0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2016-09-16 Jonathan Wakely + Marc Glisse + + * 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 * libsupc++/new_opa.cc [_GLIBCXX_HAVE_POSIX_MEMALIGN] (aligned_alloc): diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc index 9c859c1b61b..91e53a8b360 100644 --- a/libstdc++-v3/libsupc++/new_opa.cc +++ b/libstdc++-v3/libsupc++/new_opa.cc @@ -69,7 +69,7 @@ operator new (std::size_t sz, std::align_val_t al) #if _GLIBCXX_HAVE_ALIGNED_ALLOC /* 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; #endif