Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / scudo / standalone / wrappers_c_bionic.cpp
blob4fed44779b9020dfb72bac378d985fe3a582f809
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "platform.h"
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"
16 #include "platform.h"
17 #include "scudo/interface.h"
18 #include "wrappers_c.h"
19 #include "wrappers_c_checks.h"
21 #include <stdint.h>
22 #include <stdio.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)>
31 SCUDO_ALLOCATOR;
33 #include "wrappers_c.inc"
35 #undef SCUDO_ALLOCATOR
36 #undef SCUDO_PREFIX
38 // TODO(kostyak): support both allocators.
39 INTERFACE void __scudo_print_stats(void) { Allocator.printStats(); }
41 INTERFACE void
42 __scudo_get_error_info(struct scudo_error_info *error_info,
43 uintptr_t fault_addr, const char *stack_depot,
44 const char *region_info, const char *ring_buffer,
45 const char *memory, const char *memory_tags,
46 uintptr_t memory_addr, size_t memory_size) {
47 Allocator.getErrorInfo(error_info, fault_addr, stack_depot, region_info,
48 ring_buffer, memory, memory_tags, memory_addr,
49 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