1351282Sdim//===-- wrappers_c.h --------------------------------------------*- C++ -*-===//
2351282Sdim//
3351282Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4351282Sdim// See https://llvm.org/LICENSE.txt for license information.
5351282Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6351282Sdim//
7351282Sdim//===----------------------------------------------------------------------===//
8351282Sdim
9351282Sdim#ifndef SCUDO_WRAPPERS_C_H_
10351282Sdim#define SCUDO_WRAPPERS_C_H_
11351282Sdim
12351282Sdim#include "platform.h"
13351282Sdim#include "stats.h"
14351282Sdim
15351282Sdim// Bionic's struct mallinfo consists of size_t (mallinfo(3) uses int).
16351282Sdim#if SCUDO_ANDROID
17351282Sdimtypedef size_t __scudo_mallinfo_data_t;
18351282Sdim#else
19351282Sdimtypedef int __scudo_mallinfo_data_t;
20351282Sdim#endif
21351282Sdim
22351282Sdimstruct __scudo_mallinfo {
23351282Sdim  __scudo_mallinfo_data_t arena;
24351282Sdim  __scudo_mallinfo_data_t ordblks;
25351282Sdim  __scudo_mallinfo_data_t smblks;
26351282Sdim  __scudo_mallinfo_data_t hblks;
27351282Sdim  __scudo_mallinfo_data_t hblkhd;
28351282Sdim  __scudo_mallinfo_data_t usmblks;
29351282Sdim  __scudo_mallinfo_data_t fsmblks;
30351282Sdim  __scudo_mallinfo_data_t uordblks;
31351282Sdim  __scudo_mallinfo_data_t fordblks;
32351282Sdim  __scudo_mallinfo_data_t keepcost;
33351282Sdim};
34351282Sdim
35351282Sdim// Android sometimes includes malloc.h no matter what, which yields to
36351282Sdim// conflicting return types for mallinfo() if we use our own structure. So if
37351282Sdim// struct mallinfo is declared (#define courtesy of malloc.h), use it directly.
38351282Sdim#if STRUCT_MALLINFO_DECLARED
39351282Sdim#define SCUDO_MALLINFO mallinfo
40351282Sdim#else
41351282Sdim#define SCUDO_MALLINFO __scudo_mallinfo
42351282Sdim#endif
43351282Sdim
44351282Sdim#ifndef M_DECAY_TIME
45351282Sdim#define M_DECAY_TIME -100
46351282Sdim#endif
47351282Sdim
48351282Sdim#ifndef M_PURGE
49351282Sdim#define M_PURGE -101
50351282Sdim#endif
51351282Sdim
52351282Sdim#endif // SCUDO_WRAPPERS_C_H_
53