aboutsummaryrefslogtreecommitdiffstats
path: root/util-src
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-01-06 18:56:06 +0100
committerKim Alvefur <zash@zash.se>2022-01-06 18:56:06 +0100
commitd3bd9f9be5dd3322e16e7b6587e8941b803f3d11 (patch)
tree39c888b4c92b624db689af6f5659643706a6707e /util-src
parent8a97d634a4c5c5d046424c227a4b26bb9f486481 (diff)
downloadprosody-d3bd9f9be5dd3322e16e7b6587e8941b803f3d11.tar.gz
prosody-d3bd9f9be5dd3322e16e7b6587e8941b803f3d11.zip
util.pposix: Use mallinfo2() on glibc 2.33, fix #1649
Diffstat (limited to 'util-src')
-rw-r--r--util-src/pposix.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/util-src/pposix.c b/util-src/pposix.c
index 87be7e9a..a8e0720f 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -728,26 +728,33 @@ static int lc_setenv(lua_State *L) {
#ifdef WITH_MALLINFO
static int lc_meminfo(lua_State *L) {
+#if __GLIBC_PREREQ(2, 33)
+ struct mallinfo2 info = mallinfo2();
+#define MALLINFO_T size_t
+#else
struct mallinfo info = mallinfo();
+#define MALLINFO_T unsigned
+#endif
lua_createtable(L, 0, 5);
/* This is the total size of memory allocated with sbrk by malloc, in bytes. */
- lua_pushinteger(L, (unsigned)info.arena);
+ lua_pushinteger(L, (MALLINFO_T)info.arena);
lua_setfield(L, -2, "allocated");
/* This is the total size of memory allocated with mmap, in bytes. */
- lua_pushinteger(L, (unsigned)info.hblkhd);
+ lua_pushinteger(L, (MALLINFO_T)info.hblkhd);
lua_setfield(L, -2, "allocated_mmap");
/* This is the total size of memory occupied by chunks handed out by malloc. */
- lua_pushinteger(L, (unsigned)info.uordblks);
+ lua_pushinteger(L, (MALLINFO_T)info.uordblks);
lua_setfield(L, -2, "used");
/* This is the total size of memory occupied by free (not in use) chunks. */
- lua_pushinteger(L, (unsigned)info.fordblks);
+ lua_pushinteger(L, (MALLINFO_T)info.fordblks);
lua_setfield(L, -2, "unused");
/* This is the size of the top-most releasable chunk that normally borders the
end of the heap (i.e., the high end of the virtual address space's data segment). */
- lua_pushinteger(L, (unsigned)info.keepcost);
+ lua_pushinteger(L, (MALLINFO_T)info.keepcost);
lua_setfield(L, -2, "returnable");
return 1;
}
+#undef MALLINFO_T
#endif
/*