[libcxx-commits] [PATCH] D91379: [libc++] Factor out common logic for calling aligned allocation

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 12 12:28:56 PST 2020


ldionne created this revision.
Herald added subscribers: libcxx-commits, jkorous.
Herald added projects: libc++, libc++abi.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.
ldionne requested review of this revision.

There were a couple of places where we needed to call the underlying
platform's aligned allocation/deallocation function. Instead of having
the same logic all over the place, extract the logic into a pair of
helper functions __libcpp_aligned_alloc and __libcpp_aligned_free.

The code in libcxxabi/src/fallback_malloc.cpp looks like it could be
simplified after this change -- I purposefully did not simplify it
further to keep this change as straightforward as possible, since it
is touching very important parts of the library.

Also, the changes in libcxx/src/new.cpp and libcxxabi/src/stdlib_new_delete.cpp
are basically the same -- I just kept both source files in sync.

The underlying reason for this refactoring is to make it easier to support
platforms that provide aligned allocation through C11's aligned_alloc
function instead of posix_memalign. After this change, we'll only have
to add support for that in a single place.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91379

Files:
  libcxx/include/new
  libcxx/src/new.cpp
  libcxxabi/src/fallback_malloc.cpp
  libcxxabi/src/stdlib_new_delete.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91379.304935.patch
Type: text/x-patch
Size: 6244 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201112/9f1472e2/attachment.bin>


More information about the libcxx-commits mailing list