PR libstdc++/70940 optimize pmr::resource_adaptor for allocators using malloc
commita958a2e2bad4e9266f91ee927df79fcd2f982092
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Jul 2018 19:40:28 +0000 (23 19:40 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Jul 2018 19:40:28 +0000 (23 19:40 +0000)
tree2db36a97ddc96b86ee3c32f89c5cfb365cbe2c5a
parentf161ab918b751e4caceeedab97cea05ecec62be0
PR libstdc++/70940 optimize pmr::resource_adaptor for allocators using malloc

pmr::resource_adaptor can avoid allocating an oversized buffer and doing
manual alignment within that buffer when the wrapped allocator is known
to always meet the requested alignment. Specifically, if the allocator
is known to use malloc or new directly, then we can call the allocator
directly for any fundamental alignment.

PR libstdc++/70940
* include/experimental/memory_resource
(__resource_adaptor_common::_AlignMgr::_M_unadjust): Add assertion.
(__resource_adaptor_common::__guaranteed_alignment): New helper to
give maximum alignment an allocator guarantees. Specialize for known
allocators using new and malloc.
(__resource_adaptor_imp::do_allocate): Use __guaranteed_alignment.
(__resource_adaptor_imp::do_deallocate): Likewise.
* testsuite/experimental/memory_resource/new_delete_resource.cc:
Check that new and delete are called with expected sizes.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262935 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/experimental/memory_resource
libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc