76 lines · cpp
1//===-- wrappers_c_bionic.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-exception6//7//===----------------------------------------------------------------------===//8 9#include "platform.h"10 11// This is only used when compiled as part of Bionic.12#if SCUDO_ANDROID && _BIONIC13 14#include "allocator_config.h"15#include "internal_defs.h"16#include "platform.h"17#include "scudo/interface.h"18#include "wrappers_c.h"19#include "wrappers_c_checks.h"20 21#include <stdint.h>22#include <stdio.h>23 24// Regular MallocDispatch definitions.25#define SCUDO_PREFIX(name) CONCATENATE(scudo_, name)26#define SCUDO_ALLOCATOR Allocator27 28extern "C" void SCUDO_PREFIX(malloc_postinit)();29SCUDO_REQUIRE_CONSTANT_INITIALIZATION30static scudo::Allocator<scudo::Config, SCUDO_PREFIX(malloc_postinit)>31 SCUDO_ALLOCATOR;32 33#include "wrappers_c.inc"34 35#undef SCUDO_ALLOCATOR36#undef SCUDO_PREFIX37 38// TODO(kostyak): support both allocators.39INTERFACE void __scudo_print_stats(void) { Allocator.printStats(); }40 41INTERFACE 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 Allocator.getErrorInfo(error_info, fault_addr, stack_depot, stack_depot_size,47 region_info, ring_buffer, ring_buffer_size, memory,48 memory_tags, memory_addr, memory_size);49}50 51INTERFACE const char *__scudo_get_stack_depot_addr() {52 return Allocator.getStackDepotAddress();53}54 55INTERFACE size_t __scudo_get_stack_depot_size() {56 return Allocator.getStackDepotSize();57}58 59INTERFACE const char *__scudo_get_region_info_addr() {60 return Allocator.getRegionInfoArrayAddress();61}62 63INTERFACE size_t __scudo_get_region_info_size() {64 return Allocator.getRegionInfoArraySize();65}66 67INTERFACE const char *__scudo_get_ring_buffer_addr() {68 return Allocator.getRingBufferAddress();69}70 71INTERFACE size_t __scudo_get_ring_buffer_size() {72 return Allocator.getRingBufferSize();73}74 75#endif // SCUDO_ANDROID && _BIONIC76