• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2020 Free Software Foundation, Inc.
4  * Copyright (c) 2021 FUJITSU LIMITED. All rights reserved.
5  * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
6  */
7 
8 #ifndef MALLINFO_COMMON_H
9 #define MALLINFO_COMMON_H
10 
11 #include <malloc.h>
12 #include "tst_test.h"
13 #include "config.h"
14 
15 #ifdef HAVE_MALLINFO
print_mallinfo(const char * msg,struct mallinfo * m)16 static inline void print_mallinfo(const char *msg, struct mallinfo *m)
17 {
18 	tst_res(TINFO, "%s", msg);
19 
20 #define P(f) tst_res(TINFO, "%s: %d", #f, m->f)
21 	P(arena);
22 	P(ordblks);
23 	P(smblks);
24 	P(hblks);
25 	P(hblkhd);
26 	P(usmblks);
27 	P(fsmblks);
28 	P(uordblks);
29 	P(fordblks);
30 	P(keepcost);
31 }
32 #endif
33 
34 #ifdef HAVE_MALLINFO2
print_mallinfo2(const char * msg,struct mallinfo2 * m)35 static inline void print_mallinfo2(const char *msg, struct mallinfo2 *m)
36 {
37 	tst_res(TINFO, "%s", msg);
38 
39 #define P2(f) tst_res(TINFO, "%s: %ld", #f, m->f)
40 	P2(arena);
41 	P2(ordblks);
42 	P2(smblks);
43 	P2(hblks);
44 	P2(hblkhd);
45 	P2(usmblks);
46 	P2(fsmblks);
47 	P2(uordblks);
48 	P2(fordblks);
49 	P2(keepcost);
50 }
51 #endif
52 
53 #endif
54