brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 08dc679 Raw
63 lines · c
1//===-- wrappers_c.h --------------------------------------------*- 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#ifndef SCUDO_WRAPPERS_C_H_10#define SCUDO_WRAPPERS_C_H_11 12#include "platform.h"13#include "stats.h"14 15// Bionic's struct mallinfo consists of size_t (mallinfo(3) uses int).16#if SCUDO_ANDROID17typedef size_t __scudo_mallinfo_data_t;18#else19typedef int __scudo_mallinfo_data_t;20#endif21 22struct __scudo_mallinfo {23  __scudo_mallinfo_data_t arena;24  __scudo_mallinfo_data_t ordblks;25  __scudo_mallinfo_data_t smblks;26  __scudo_mallinfo_data_t hblks;27  __scudo_mallinfo_data_t hblkhd;28  __scudo_mallinfo_data_t usmblks;29  __scudo_mallinfo_data_t fsmblks;30  __scudo_mallinfo_data_t uordblks;31  __scudo_mallinfo_data_t fordblks;32  __scudo_mallinfo_data_t keepcost;33};34 35struct __scudo_mallinfo2 {36  size_t arena;37  size_t ordblks;38  size_t smblks;39  size_t hblks;40  size_t hblkhd;41  size_t usmblks;42  size_t fsmblks;43  size_t uordblks;44  size_t fordblks;45  size_t keepcost;46};47 48// Android sometimes includes malloc.h no matter what, which yields to49// conflicting return types for mallinfo() if we use our own structure. So if50// struct mallinfo is declared (#define courtesy of malloc.h), use it directly.51#if STRUCT_MALLINFO_DECLARED52#define SCUDO_MALLINFO mallinfo53#else54#define SCUDO_MALLINFO __scudo_mallinfo55#endif56 57#if !SCUDO_ANDROID || !_BIONIC58extern "C" void malloc_postinit();59extern HIDDEN scudo::Allocator<scudo::Config, malloc_postinit> Allocator;60#endif61 62#endif // SCUDO_WRAPPERS_C_H_63