diff options
author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-02-13 09:46:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-13 09:46:15 +0100 |
commit | 44b0793e88503b4b70a569c0579f7a79b587f627 (patch) | |
tree | 675ef88ebb4f6ed188ecf4017a10b81bfa6da834 | |
parent | Merge pull request #8076 from qlyoung/doc-lttng-fork-preload (diff) | |
parent | lib: support mallinfo2() (diff) | |
download | frr-44b0793e88503b4b70a569c0579f7a79b587f627.tar.xz frr-44b0793e88503b4b70a569c0579f7a79b587f627.zip |
Merge pull request #8036 from qlyoung/disable-mallinfo
lib: support mallinfo2() if available
Diffstat (limited to '')
-rwxr-xr-x | configure.ac | 23 | ||||
-rw-r--r-- | lib/lib_vty.c | 6 |
2 files changed, 28 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 09ec23ab7..266f37a11 100755 --- a/configure.ac +++ b/configure.ac @@ -2366,6 +2366,29 @@ if test "$frr_cv_mallinfo" = "yes"; then AC_DEFINE([HAVE_MALLINFO], [1], [mallinfo]) fi +AC_CACHE_CHECK([whether mallinfo2 is available], [frr_cv_mallinfo2], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([FRR_INCLUDES [ +#ifdef HAVE_MALLOC_H +#include <malloc.h> +#endif +#ifdef HAVE_MALLOC_NP_H +#include <malloc_np.h> +#endif +#ifdef HAVE_MALLOC_MALLOC_H +#include <malloc/malloc.h> +#endif +]], [[ +struct mallinfo2 ac_x; ac_x = mallinfo2 (); +]])], [ + frr_cv_mallinfo2=yes + ], [ + frr_cv_mallinfo2=no + ]) +]) +if test "$frr_cv_mallinfo2" = "yes"; then + AC_DEFINE([HAVE_MALLINFO2], [1], [mallinfo2]) +fi + AC_MSG_CHECKING([whether malloc_usable_size is available]) AC_LINK_IFELSE([AC_LANG_PROGRAM([FRR_INCLUDES [ #ifdef HAVE_MALLOC_H diff --git a/lib/lib_vty.c b/lib/lib_vty.c index cd8b5c980..128261a39 100644 --- a/lib/lib_vty.c +++ b/lib/lib_vty.c @@ -43,10 +43,14 @@ #include "vty.h" #include "command.h" -#ifdef HAVE_MALLINFO +#if defined(HAVE_MALLINFO2) || defined(HAVE_MALLINFO) static int show_memory_mallinfo(struct vty *vty) { +#if defined(HAVE_MALLINFO2) + struct mallinfo2 minfo = mallinfo2(); +#elif defined(HAVE_MALLINFO) struct mallinfo minfo = mallinfo(); +#endif char buf[MTYPE_MEMSTR_LEN]; vty_out(vty, "System allocator statistics:\n"); |