xref: /freebsd-src/contrib/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_c.cpp (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
168d75effSDimitry Andric //===-- wrappers_c.cpp ------------------------------------------*- C++ -*-===//
268d75effSDimitry Andric //
368d75effSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
468d75effSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
568d75effSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
668d75effSDimitry Andric //
768d75effSDimitry Andric //===----------------------------------------------------------------------===//
868d75effSDimitry Andric 
968d75effSDimitry Andric #include "platform.h"
1068d75effSDimitry Andric 
1168d75effSDimitry Andric // Skip this compilation unit if compiled as part of Bionic.
1268d75effSDimitry Andric #if !SCUDO_ANDROID || !_BIONIC
1368d75effSDimitry Andric 
1468d75effSDimitry Andric #include "allocator_config.h"
15*5f757f3fSDimitry Andric #include "internal_defs.h"
16*5f757f3fSDimitry Andric #include "platform.h"
17*5f757f3fSDimitry Andric #include "scudo/interface.h"
1868d75effSDimitry Andric #include "wrappers_c.h"
1968d75effSDimitry Andric #include "wrappers_c_checks.h"
2068d75effSDimitry Andric 
2168d75effSDimitry Andric #include <stdint.h>
2268d75effSDimitry Andric #include <stdio.h>
2368d75effSDimitry Andric 
24480093f4SDimitry Andric #define SCUDO_PREFIX(name) name
25480093f4SDimitry Andric #define SCUDO_ALLOCATOR Allocator
26480093f4SDimitry Andric 
275ffd83dbSDimitry Andric // Export the static allocator so that the C++ wrappers can access it.
2868d75effSDimitry Andric // Technically we could have a completely separated heap for C & C++ but in
2968d75effSDimitry Andric // reality the amount of cross pollination between the two is staggering.
30fe6060f1SDimitry Andric SCUDO_REQUIRE_CONSTANT_INITIALIZATION
315ffd83dbSDimitry Andric scudo::Allocator<scudo::Config, SCUDO_PREFIX(malloc_postinit)> SCUDO_ALLOCATOR;
3268d75effSDimitry Andric 
3368d75effSDimitry Andric #include "wrappers_c.inc"
34480093f4SDimitry Andric 
3568d75effSDimitry Andric #undef SCUDO_ALLOCATOR
3668d75effSDimitry Andric #undef SCUDO_PREFIX
3768d75effSDimitry Andric 
__scudo_print_stats(void)38480093f4SDimitry Andric extern "C" INTERFACE void __scudo_print_stats(void) { Allocator.printStats(); }
3968d75effSDimitry Andric 
4068d75effSDimitry Andric #endif // !SCUDO_ANDROID || !_BIONIC
41