MemAlloc.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //===- MemAlloc.cpp - Memory allocation functions -------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "llvm/Support/MemAlloc.h"
  9. #include <new>
  10. // These are out of line to have __cpp_aligned_new not affect ABI.
  11. LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void *
  12. llvm::allocate_buffer(size_t Size, size_t Alignment) {
  13. return ::operator new(Size
  14. #ifdef __cpp_aligned_new
  15. ,
  16. std::align_val_t(Alignment)
  17. #endif
  18. );
  19. }
  20. void llvm::deallocate_buffer(void *Ptr, size_t Size, size_t Alignment) {
  21. ::operator delete(Ptr
  22. #ifdef __cpp_sized_deallocation
  23. ,
  24. Size
  25. #endif
  26. #ifdef __cpp_aligned_new
  27. ,
  28. std::align_val_t(Alignment)
  29. #endif
  30. );
  31. }