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
9#include "llvm/Support/MemAlloc.h"
10
11// These are out of line to have __cpp_aligned_new not affect ABI.
12
13LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void *
14llvm::allocate_buffer(size_t Size, size_t Alignment) {
15  return ::operator new(Size
16#ifdef __cpp_aligned_new
17                        ,
18                        std::align_val_t(Alignment)
19#endif
20  );
21}
22
23void llvm::deallocate_buffer(void *Ptr, size_t Size, size_t Alignment) {
24  ::operator delete(Ptr
25#ifdef __cpp_sized_deallocation
26                    ,
27                    Size
28#endif
29#ifdef __cpp_aligned_new
30                    ,
31                    std::align_val_t(Alignment)
32#endif
33  );
34}
35