From 24ccb6ebc5e13a128aaedd3a2eb52eef3adf6dcd Mon Sep 17 00:00:00 2001 From: Romain Naour Date: Thu, 30 Jul 2015 16:55:45 +0200 Subject: build-sys: check for mallinfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mallinfo is not specified by POSIX or the C standards, therefore it's not available for all libc libraries (musl). Add the ability to disable mallinfo statistics. Fixes: selinux-util.c: In function ‘mac_selinux_init’: selinux-util.c:70:25: error: storage size of ‘before_mallinfo’ isn’t known struct mallinfo before_mallinfo, after_mallinfo; Signed-off-by: Romain Naour --- src/shared/selinux-util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c index 756215e8ef..4e0866be5f 100644 --- a/src/shared/selinux-util.c +++ b/src/shared/selinux-util.c @@ -67,7 +67,10 @@ int mac_selinux_init(const char *prefix) { #ifdef HAVE_SELINUX usec_t before_timestamp, after_timestamp; + +#ifdef HAVE_MALLINFO struct mallinfo before_mallinfo, after_mallinfo; +#endif if (!mac_selinux_use()) return 0; @@ -75,7 +78,10 @@ int mac_selinux_init(const char *prefix) { if (label_hnd) return 0; +#ifdef HAVE_MALLINFO before_mallinfo = mallinfo(); +#endif + before_timestamp = now(CLOCK_MONOTONIC); if (prefix) { @@ -92,9 +98,14 @@ int mac_selinux_init(const char *prefix) { r = security_getenforce() == 1 ? -errno : 0; } else { char timespan[FORMAT_TIMESPAN_MAX]; + +#ifdef HAVE_MALLINFO int l; +#endif after_timestamp = now(CLOCK_MONOTONIC); + +#ifdef HAVE_MALLINFO after_mallinfo = mallinfo(); l = after_mallinfo.uordblks > before_mallinfo.uordblks ? after_mallinfo.uordblks - before_mallinfo.uordblks : 0; @@ -102,6 +113,10 @@ int mac_selinux_init(const char *prefix) { 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 -- cgit v1.2.3-54-g00ecf