mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
lib:util: prefer mallinfo2() over mallinfo() if available
Prefer mallinfo2() with 'size_t' fields over deprecated mallinfo() (with 'int' fields which may wrap around zero and so be inaccurate on a 64-bit system) and move relevant checks to lib/util/wscript_configure because mallinfo() is not used beyond 'samba-util'. Suggested-by: Andreas Schneider <asn@samba.org> Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
f55a357c6b
commit
b3146763a4
@ -76,12 +76,37 @@ static void talloc_report_printf_helper(
|
||||
void talloc_full_report_printf(TALLOC_CTX *root, FILE *f)
|
||||
{
|
||||
talloc_report_depth_cb(root, 0, -1, talloc_report_printf_helper, f);
|
||||
|
||||
#ifdef HAVE_MALLINFO
|
||||
#if defined(HAVE_MALLINFO2)
|
||||
{
|
||||
struct mallinfo mi;
|
||||
struct mallinfo2 mi2 = mallinfo2();
|
||||
|
||||
fprintf(f,
|
||||
"mallinfo:\n"
|
||||
" arena: %zu\n"
|
||||
" ordblks: %zu\n"
|
||||
" smblks: %zu\n"
|
||||
" hblks: %zu\n"
|
||||
" hblkhd: %zu\n"
|
||||
" usmblks: %zu\n"
|
||||
" fsmblks: %zu\n"
|
||||
" uordblks: %zu\n"
|
||||
" fordblks: %zu\n"
|
||||
" keepcost: %zu\n",
|
||||
mi2.arena,
|
||||
mi2.ordblks,
|
||||
mi2.smblks,
|
||||
mi2.hblks,
|
||||
mi2.hblkhd,
|
||||
mi2.usmblks,
|
||||
mi2.fsmblks,
|
||||
mi2.uordblks,
|
||||
mi2.fordblks,
|
||||
mi2.keepcost);
|
||||
}
|
||||
#elif defined(HAVE_MALLINFO)
|
||||
{
|
||||
struct mallinfo mi = mallinfo();
|
||||
|
||||
mi = mallinfo();
|
||||
fprintf(f,
|
||||
"mallinfo:\n"
|
||||
" arena: %d\n"
|
||||
@ -105,5 +130,5 @@ void talloc_full_report_printf(TALLOC_CTX *root, FILE *f)
|
||||
mi.fordblks,
|
||||
mi.keepcost);
|
||||
}
|
||||
#endif /* HAVE_MALLINFO */
|
||||
#endif /* HAVE_MALLINFO2 or HAVE_MALLINFO */
|
||||
}
|
||||
|
@ -122,6 +122,18 @@ conf.CHECK_CODE('struct statvfs buf; buf.f_flags = 0',
|
||||
local_include=False,
|
||||
execute=False)
|
||||
|
||||
# Check for mallinfo2() first and fallback to mallinfo() if not found
|
||||
body = '''mi.arena + mi.ordblks + mi.smblks + mi.hblks + mi.hblkhd +
|
||||
mi.usmblks + mi.fsmblks + mi.uordblks + mi.fordblks + mi.keepcost'''
|
||||
if not conf.CHECK_CODE('''struct mallinfo2 mi = mallinfo2(); return %s;'''
|
||||
% body, 'HAVE_MALLINFO2',
|
||||
msg="Checking for mallinfo2()",
|
||||
headers='malloc.h'):
|
||||
conf.CHECK_CODE('''struct mallinfo mi = mallinfo(); return %s;'''
|
||||
% body, 'HAVE_MALLINFO',
|
||||
msg="Checking for mallinfo()",
|
||||
headers='malloc.h')
|
||||
|
||||
#
|
||||
# systemd removed the libsystemd-daemon and libsystemd-journal libraries. In newer
|
||||
# versions it is only libsystemd. As waf pkg-config handling does not provide
|
||||
|
@ -1649,18 +1649,6 @@ int main(void) {
|
||||
define='HAVE_UNSHARE_CLONE_FS',
|
||||
msg='for Linux unshare(CLONE_FS)')
|
||||
|
||||
# Check for mallinfo
|
||||
conf.CHECK_CODE('''
|
||||
struct mallinfo mi;
|
||||
int tmp;
|
||||
|
||||
mi = mallinfo();
|
||||
tmp = mi.arena + mi.ordblks + mi.smblks + mi.hblks +
|
||||
mi.hblkhd + mi.usmblks + mi.fsmblks + mi.uordblks +
|
||||
mi.fordblks + mi.keepcost;
|
||||
return tmp;
|
||||
''', 'HAVE_MALLINFO', msg="Checking for mallinfo()", headers='malloc.h')
|
||||
|
||||
#
|
||||
# cluster support (CTDB)
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user