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
20namespace __copyprof {
21
22// Minimum alignment (in bytes) of allocations returned by the CopyProf
23// allocator.
24constexpr uptr kMinAlignment = 8;
25
26// Initializes the copyprof allocator at startup.
27void InitializeCopyProfAllocator();
28
29// CopyProf specific memory allocation / deallocation routines and libc
30// surrogates.
31void* CopyProfAllocate(uptr size, uptr align);
32void CopyProfDeallocate(void* ptr, uptr size, uptr align);
33void* CopyProfMalloc(uptr size);
34void CopyProfFree(void* ptr);
35void* CopyProfCalloc(uptr num, uptr size);
36void* CopyProfRealloc(void* ptr, uptr size);
37void* CopyProfReallocarray(void* ptr, uptr num, uptr size);
38void* CopyProfValloc(uptr size);
39void* CopyProfPvalloc(uptr size);
40int CopyProfPosixMemalign(void** memptr, uptr alignment, uptr size);
41uptr CopyProfMallocUsableSize(const void* ptr);
42
43} // namespace __copyprof
44
45#endif // COPYPROF_ALLOCATOR_H
46