xref: /freebsd-src/contrib/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_c.cpp (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
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"
1568d75effSDimitry Andric #include "wrappers_c.h"
1668d75effSDimitry Andric #include "wrappers_c_checks.h"
1768d75effSDimitry Andric 
1868d75effSDimitry Andric #include <stdint.h>
1968d75effSDimitry Andric #include <stdio.h>
2068d75effSDimitry Andric 
21480093f4SDimitry Andric #define SCUDO_PREFIX(name) name
22480093f4SDimitry Andric #define SCUDO_ALLOCATOR Allocator
23480093f4SDimitry Andric 
24480093f4SDimitry Andric extern "C" void SCUDO_PREFIX(malloc_postinit)();
25*5ffd83dbSDimitry Andric 
26*5ffd83dbSDimitry Andric // Export the static allocator so that the C++ wrappers can access it.
2768d75effSDimitry Andric // Technically we could have a completely separated heap for C & C++ but in
2868d75effSDimitry Andric // reality the amount of cross pollination between the two is staggering.
29*5ffd83dbSDimitry Andric scudo::Allocator<scudo::Config, SCUDO_PREFIX(malloc_postinit)> SCUDO_ALLOCATOR;
3068d75effSDimitry Andric 
3168d75effSDimitry Andric #include "wrappers_c.inc"
32480093f4SDimitry Andric 
3368d75effSDimitry Andric #undef SCUDO_ALLOCATOR
3468d75effSDimitry Andric #undef SCUDO_PREFIX
3568d75effSDimitry Andric 
36480093f4SDimitry Andric extern "C" INTERFACE void __scudo_print_stats(void) { Allocator.printStats(); }
3768d75effSDimitry Andric 
3868d75effSDimitry Andric #endif // !SCUDO_ANDROID || !_BIONIC
39