1 //===-- wrappers_c_bionic.cpp -----------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
11 // This is only used when compiled as part of Bionic.
12 #if SCUDO_ANDROID && _BIONIC
14 #include "allocator_config.h"
15 #include "wrappers_c.h"
16 #include "wrappers_c_checks.h"
21 // Regular MallocDispatch definitions.
22 #define SCUDO_PREFIX(name) CONCATENATE(scudo_, name)
23 #define SCUDO_ALLOCATOR Allocator
25 extern "C" void SCUDO_PREFIX(malloc_postinit)();
26 static scudo::Allocator<scudo::AndroidConfig, SCUDO_PREFIX(malloc_postinit)>
28 // Pointer to the static allocator so that the C++ wrappers can access it.
29 // Technically we could have a completely separated heap for C & C++ but in
30 // reality the amount of cross pollination between the two is staggering.
31 scudo::Allocator<scudo::AndroidConfig, SCUDO_PREFIX(malloc_postinit)> *
32 CONCATENATE(SCUDO_ALLOCATOR, Ptr) = &SCUDO_ALLOCATOR;
34 #include "wrappers_c.inc"
36 #undef SCUDO_ALLOCATOR
39 // Svelte MallocDispatch definitions.
40 #define SCUDO_PREFIX(name) CONCATENATE(scudo_svelte_, name)
41 #define SCUDO_ALLOCATOR SvelteAllocator
43 extern "C" void SCUDO_PREFIX(malloc_postinit)();
44 static scudo::Allocator<scudo::AndroidSvelteConfig,
45 SCUDO_PREFIX(malloc_postinit)>
47 // Pointer to the static allocator so that the C++ wrappers can access it.
48 // Technically we could have a completely separated heap for C & C++ but in
49 // reality the amount of cross pollination between the two is staggering.
50 scudo::Allocator<scudo::AndroidSvelteConfig, SCUDO_PREFIX(malloc_postinit)> *
51 CONCATENATE(SCUDO_ALLOCATOR, Ptr) = &SCUDO_ALLOCATOR;
53 #include "wrappers_c.inc"
55 #undef SCUDO_ALLOCATOR
58 // The following is the only function that will end up initializing both
59 // allocators, which will result in a slight increase in memory footprint.
60 INTERFACE void __scudo_print_stats(void) {
61 Allocator.printStats();
62 SvelteAllocator.printStats();
65 #endif // SCUDO_ANDROID && _BIONIC