--- a/meson.build 2021-05-13 20:47:21.487670275 +0000 +++ b/meson.build 2021-05-13 20:53:12.977688147 +0000 @@ -542,6 +542,12 @@ else conf.set10('HAVE_GETRANDOM', have) endif +if cc.has_function('mallinfo', prefix : '''#include ''') + conf.set10('HAVE_MALLINFO', true) +else + conf.set10('HAVE_MALLINFO', false) +endif + ##################################################################### vcs_tagger = [project_source_root + '/tools/meson-vcs-tag.sh', --- a/src/basic/selinux-util.c 2021-05-13 20:17:47.044246714 +0000 +++ b/src/basic/selinux-util.c 2021-05-13 21:00:56.591045053 +0000 @@ -75,9 +75,13 @@ void mac_selinux_retest(void) { int mac_selinux_init(void) { #if HAVE_SELINUX usec_t before_timestamp, after_timestamp; +#if defined (__GLIBC__) && defined (HAVE_MALLINFO) struct mallinfo before_mallinfo, after_mallinfo; +#endif char timespan[FORMAT_TIMESPAN_MAX]; +#ifdef HAVE_MALLINFO int l; +#endif selinux_set_callback(SELINUX_CB_POLICYLOAD, (union selinux_callback) mac_selinux_reload); @@ -87,7 +91,9 @@ int mac_selinux_init(void) { if (!mac_selinux_use()) return 0; +#if defined (__GLIBC__) && defined (HAVE_MALLINFO) before_mallinfo = mallinfo(); +#endif before_timestamp = now(CLOCK_MONOTONIC); label_hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0); @@ -95,6 +101,7 @@ int mac_selinux_init(void) { return log_enforcing_errno(errno, "Failed to initialize SELinux labeling handle: %m"); after_timestamp = now(CLOCK_MONOTONIC); +#if defined (__GLIBC__) && defined (HAVE_MALLINFO) after_mallinfo = mallinfo(); l = after_mallinfo.uordblks > before_mallinfo.uordblks ? after_mallinfo.uordblks - before_mallinfo.uordblks : 0; @@ -102,6 +109,10 @@ int mac_selinux_init(void) { log_debug("Successfully loaded SELinux database in %s, size on heap is %iK.", format_timespan(timespan, sizeof(timespan), after_timestamp - before_timestamp, 0), (l+1023)/1024); +#else + log_debug("Successfully loaded SELinux database in %s", + format_timespan(timespan, sizeof(timespan), after_timestamp - before_timestamp, 0)); +#endif #endif return 0;