xref: /freebsd/contrib/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_c.h (revision ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
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-exception
6 //
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_ANDROID
17 typedef size_t __scudo_mallinfo_data_t;
18 #else
19 typedef int __scudo_mallinfo_data_t;
20 #endif
21 
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;
33 };
34 
35 // Android sometimes includes malloc.h no matter what, which yields to
36 // conflicting return types for mallinfo() if we use our own structure. So if
37 // struct mallinfo is declared (#define courtesy of malloc.h), use it directly.
38 #if STRUCT_MALLINFO_DECLARED
39 #define SCUDO_MALLINFO mallinfo
40 #else
41 #define SCUDO_MALLINFO __scudo_mallinfo
42 #endif
43 
44 #endif // SCUDO_WRAPPERS_C_H_
45