]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/scudo/standalone/wrappers_c_bionic.cc
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / scudo / standalone / wrappers_c_bionic.cc
1 //===-- wrappers_c_bionic.cc ------------------------------------*- 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 #include "platform.h"
10
11 // This is only used when compiled as part of Bionic.
12 #if SCUDO_ANDROID && _BIONIC
13
14 #include "allocator_config.h"
15 #include "wrappers_c.h"
16 #include "wrappers_c_checks.h"
17
18 #include <stdint.h>
19 #include <stdio.h>
20
21 static scudo::Allocator<scudo::AndroidConfig> Allocator;
22 static scudo::Allocator<scudo::AndroidSvelteConfig> SvelteAllocator;
23
24 extern "C" {
25
26 // Regular MallocDispatch definitions.
27 #define SCUDO_PREFIX(name) CONCATENATE(scudo_, name)
28 #define SCUDO_ALLOCATOR Allocator
29 #include "wrappers_c.inc"
30 #undef SCUDO_ALLOCATOR
31 #undef SCUDO_PREFIX
32
33 // Svelte MallocDispatch definitions.
34 #define SCUDO_PREFIX(name) CONCATENATE(scudo_svelte_, name)
35 #define SCUDO_ALLOCATOR SvelteAllocator
36 #include "wrappers_c.inc"
37 #undef SCUDO_ALLOCATOR
38 #undef SCUDO_PREFIX
39
40 // The following is the only function that will end up initializing both
41 // allocators, which will result in a slight increase in memory footprint.
42 INTERFACE void __scudo_print_stats(void) {
43   Allocator.printStats();
44   SvelteAllocator.printStats();
45 }
46
47 } // extern "C"
48
49 #endif // SCUDO_ANDROID && _BIONIC