xref: /freebsd/contrib/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_c.cpp (revision ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
1 //===-- wrappers_c.cpp ------------------------------------------*- 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 // Skip this compilation unit if 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 #define SCUDO_PREFIX(name) name
22 #define SCUDO_ALLOCATOR Allocator
23 
24 extern "C" void SCUDO_PREFIX(malloc_postinit)();
25 
26 // Export the static allocator so that the C++ wrappers can access it.
27 // Technically we could have a completely separated heap for C & C++ but in
28 // reality the amount of cross pollination between the two is staggering.
29 SCUDO_REQUIRE_CONSTANT_INITIALIZATION
30 scudo::Allocator<scudo::Config, SCUDO_PREFIX(malloc_postinit)> SCUDO_ALLOCATOR;
31 
32 #include "wrappers_c.inc"
33 
34 #undef SCUDO_ALLOCATOR
35 #undef SCUDO_PREFIX
36 
37 extern "C" INTERFACE void __scudo_print_stats(void) { Allocator.printStats(); }
38 
39 #endif // !SCUDO_ANDROID || !_BIONIC
40