Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/compiler-rt/lib/nsan/nsan_allocator.h
213766 views
1
//===-- nsan_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
#ifndef NSAN_ALLOCATOR_H
10
#define NSAN_ALLOCATOR_H
11
12
#include "sanitizer_common/sanitizer_common.h"
13
14
namespace __nsan {
15
16
struct NsanThreadLocalMallocStorage {
17
// Allocator cache contains atomic_uint64_t which must be 8-byte aligned.
18
alignas(8) uptr allocator_cache[96 * (512 * 8 + 16)]; // Opaque.
19
void Init();
20
void CommitBack();
21
22
private:
23
// These objects are allocated via mmap() and are zero-initialized.
24
NsanThreadLocalMallocStorage() {}
25
};
26
27
void NsanAllocatorInit();
28
void NsanDeallocate(void *ptr);
29
30
void *nsan_malloc(uptr size);
31
void *nsan_calloc(uptr nmemb, uptr size);
32
void *nsan_realloc(void *ptr, uptr size);
33
void *nsan_reallocarray(void *ptr, uptr nmemb, uptr size);
34
void *nsan_valloc(uptr size);
35
void *nsan_pvalloc(uptr size);
36
void *nsan_aligned_alloc(uptr alignment, uptr size);
37
void *nsan_memalign(uptr alignment, uptr size);
38
int nsan_posix_memalign(void **memptr, uptr alignment, uptr size);
39
40
} // namespace __nsan
41
#endif // NSAN_ALLOCATOR_H
42
43