xref: /freebsd/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_allocator_interface.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===-- sanitizer_allocator_interface.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 // Re-declaration of functions from public sanitizer allocator interface.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef SANITIZER_ALLOCATOR_INTERFACE_H
14 #define SANITIZER_ALLOCATOR_INTERFACE_H
15 
16 #include "sanitizer_internal_defs.h"
17 
18 using __sanitizer::uptr;
19 
20 extern "C" {
21 SANITIZER_INTERFACE_ATTRIBUTE
22 uptr __sanitizer_get_estimated_allocated_size(uptr size);
23 SANITIZER_INTERFACE_ATTRIBUTE int __sanitizer_get_ownership(const void *p);
24 SANITIZER_INTERFACE_ATTRIBUTE const void *__sanitizer_get_allocated_begin(
25     const void *p);
26 SANITIZER_INTERFACE_ATTRIBUTE uptr
27 __sanitizer_get_allocated_size(const void *p);
28 SANITIZER_INTERFACE_ATTRIBUTE uptr
29 __sanitizer_get_allocated_size_fast(const void *p);
30 SANITIZER_INTERFACE_ATTRIBUTE uptr __sanitizer_get_current_allocated_bytes();
31 SANITIZER_INTERFACE_ATTRIBUTE uptr __sanitizer_get_heap_size();
32 SANITIZER_INTERFACE_ATTRIBUTE uptr __sanitizer_get_free_bytes();
33 SANITIZER_INTERFACE_ATTRIBUTE uptr __sanitizer_get_unmapped_bytes();
34 
35 SANITIZER_INTERFACE_ATTRIBUTE int __sanitizer_install_malloc_and_free_hooks(
36     void (*malloc_hook)(const void *, uptr),
37     void (*free_hook)(const void *));
38 
39 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
40     void __sanitizer_malloc_hook(void *ptr, uptr size);
41 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
42     void __sanitizer_free_hook(void *ptr);
43 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE int
44 __sanitizer_ignore_free_hook(void *ptr);
45 
46 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
47 __sanitizer_purge_allocator();
48 
49 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
50 __sanitizer_print_memory_profile(uptr top_percent, uptr max_number_of_contexts);
51 }  // extern "C"
52 
53 #endif  // SANITIZER_ALLOCATOR_INTERFACE_H
54