| 1 | //===-- copyprof_allocator.h ----------------------------------*- C++ -*-===// |
| 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 | /// This file declares the standalone memory allocator interface for CopyProf, |
| 10 | /// enabling isolated memory management for internal runtime structures. |
| 11 | /// |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef COPYPROF_ALLOCATOR_H |
| 15 | #define COPYPROF_ALLOCATOR_H |
| 16 | |
| 17 | #include "copyprof_internal.h" |
| 18 | #include "sanitizer_common/sanitizer_internal_defs.h" |
| 19 | |
| 20 | namespace __copyprof { |
| 21 | |
| 22 | // Minimum alignment (in bytes) of allocations returned by the CopyProf |
| 23 | // allocator. |
| 24 | constexpr uptr kMinAlignment = 8; |
| 25 | |
| 26 | // Initializes the copyprof allocator at startup. |
| 27 | void InitializeCopyProfAllocator(); |
| 28 | |
| 29 | // CopyProf specific memory allocation / deallocation routines and libc |
| 30 | // surrogates. |
| 31 | void* CopyProfAllocate(uptr size, uptr align); |
| 32 | void CopyProfDeallocate(void* ptr, uptr size, uptr align); |
| 33 | void* CopyProfMalloc(uptr size); |
| 34 | void CopyProfFree(void* ptr); |
| 35 | void* CopyProfCalloc(uptr num, uptr size); |
| 36 | void* CopyProfRealloc(void* ptr, uptr size); |
| 37 | void* CopyProfReallocarray(void* ptr, uptr num, uptr size); |
| 38 | void* CopyProfValloc(uptr size); |
| 39 | void* CopyProfPvalloc(uptr size); |
| 40 | int CopyProfPosixMemalign(void** memptr, uptr alignment, uptr size); |
| 41 | uptr CopyProfMallocUsableSize(const void* ptr); |
| 42 | |
| 43 | } // namespace __copyprof |
| 44 | |
| 45 | #endif // COPYPROF_ALLOCATOR_H |
| 46 | |