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 "internal_defs.h"
17 #include "scudo/interface.h"
18 #include "wrappers_c.h"
19 #include "wrappers_c_checks.h"
24 // Regular MallocDispatch definitions.
25 #define SCUDO_PREFIX(name) CONCATENATE(scudo_, name)
26 #define SCUDO_ALLOCATOR Allocator
28 extern "C" void SCUDO_PREFIX(malloc_postinit
)();
29 SCUDO_REQUIRE_CONSTANT_INITIALIZATION
30 static scudo::Allocator
<scudo::Config
, SCUDO_PREFIX(malloc_postinit
)>
33 #include "wrappers_c.inc"
35 #undef SCUDO_ALLOCATOR
38 // TODO(kostyak): support both allocators.
39 INTERFACE
void __scudo_print_stats(void) { Allocator
.printStats(); }
41 INTERFACE
void __scudo_get_error_info(
42 struct scudo_error_info
*error_info
, uintptr_t fault_addr
,
43 const char *stack_depot
, size_t stack_depot_size
, const char *region_info
,
44 const char *ring_buffer
, size_t ring_buffer_size
, const char *memory
,
45 const char *memory_tags
, uintptr_t memory_addr
, size_t memory_size
) {
46 (void)(stack_depot_size
);
47 Allocator
.getErrorInfo(error_info
, fault_addr
, stack_depot
, region_info
,
48 ring_buffer
, ring_buffer_size
, memory
, memory_tags
,
49 memory_addr
, memory_size
);
52 INTERFACE
const char *__scudo_get_stack_depot_addr() {
53 return Allocator
.getStackDepotAddress();
56 INTERFACE
size_t __scudo_get_stack_depot_size() {
57 return sizeof(scudo::StackDepot
);
60 INTERFACE
const char *__scudo_get_region_info_addr() {
61 return Allocator
.getRegionInfoArrayAddress();
64 INTERFACE
size_t __scudo_get_region_info_size() {
65 return Allocator
.getRegionInfoArraySize();
68 INTERFACE
const char *__scudo_get_ring_buffer_addr() {
69 return Allocator
.getRingBufferAddress();
72 INTERFACE
size_t __scudo_get_ring_buffer_size() {
73 return Allocator
.getRingBufferSize();
76 #endif // SCUDO_ANDROID && _BIONIC