1 //===-- wrappers_c.h --------------------------------------------*- 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 //===----------------------------------------------------------------------===//
9 #ifndef SCUDO_WRAPPERS_C_H_
10 #define SCUDO_WRAPPERS_C_H_
15 // Bionic's struct mallinfo consists of size_t (mallinfo(3) uses int).
17 typedef size_t __scudo_mallinfo_data_t
;
19 typedef int __scudo_mallinfo_data_t
;
22 struct __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
;
35 struct __scudo_mallinfo2
{
48 // Android sometimes includes malloc.h no matter what, which yields to
49 // conflicting return types for mallinfo() if we use our own structure. So if
50 // struct mallinfo is declared (#define courtesy of malloc.h), use it directly.
51 #if STRUCT_MALLINFO_DECLARED
52 #define SCUDO_MALLINFO mallinfo
54 #define SCUDO_MALLINFO __scudo_mallinfo
57 #if !SCUDO_ANDROID || !_BIONIC
58 extern "C" void malloc_postinit();
59 extern HIDDEN
scudo::Allocator
<scudo::Config
, malloc_postinit
> Allocator
;
62 #endif // SCUDO_WRAPPERS_C_H_