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