llvm/compiler-rt/lib/memprof/memprof_allocator.h

//===-- memprof_allocator.h ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of MemProfiler, a memory profiler.
//
// MemProf-private header for memprof_allocator.cpp.
//===----------------------------------------------------------------------===//

#ifndef MEMPROF_ALLOCATOR_H
#define MEMPROF_ALLOCATOR_H

#include "memprof_flags.h"
#include "memprof_interceptors.h"
#include "memprof_internal.h"
#include "sanitizer_common/sanitizer_allocator.h"
#include "sanitizer_common/sanitizer_list.h"

#if !defined(__x86_64__)
#error Unsupported platform
#endif
#if !SANITIZER_CAN_USE_ALLOCATOR64
#error Only 64-bit allocator supported
#endif

namespace __memprof {

enum AllocType {};

void InitializeAllocator();

struct MemprofMapUnmapCallback {};

constexpr uptr kAllocatorSpace =;
constexpr uptr kAllocatorSize =; // 4T.
SizeClassMap;
template <typename AddressSpaceViewTy>
struct AP64 {};

PrimaryAllocatorASVT;
PrimaryAllocator;

static const uptr kNumberOfSizeClasses =;

MemprofAllocatorASVT;
MemprofAllocator;
AllocatorCache;

struct MemprofThreadLocalMallocStorage {};

void *memprof_memalign(uptr alignment, uptr size, BufferedStackTrace *stack,
                       AllocType alloc_type);
void memprof_free(void *ptr, BufferedStackTrace *stack, AllocType alloc_type);
void memprof_delete(void *ptr, uptr size, uptr alignment,
                    BufferedStackTrace *stack, AllocType alloc_type);

void *memprof_malloc(uptr size, BufferedStackTrace *stack);
void *memprof_calloc(uptr nmemb, uptr size, BufferedStackTrace *stack);
void *memprof_realloc(void *p, uptr size, BufferedStackTrace *stack);
void *memprof_reallocarray(void *p, uptr nmemb, uptr size,
                           BufferedStackTrace *stack);
void *memprof_valloc(uptr size, BufferedStackTrace *stack);
void *memprof_pvalloc(uptr size, BufferedStackTrace *stack);

void *memprof_aligned_alloc(uptr alignment, uptr size,
                            BufferedStackTrace *stack);
int memprof_posix_memalign(void **memptr, uptr alignment, uptr size,
                           BufferedStackTrace *stack);
uptr memprof_malloc_usable_size(const void *ptr);

void PrintInternalAllocatorStats();

} // namespace __memprof
#endif // MEMPROF_ALLOCATOR_H