mallinfo is also available at illumos based distributions but some GLIBC lookup
need to be excluded.
uname return -1 on error and non-negative value upon success. This also works
for Linux which returns -1 on error.
--
You received this message because you are subscribed to the Google Groups
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prosody-dev/4f5d79a9f8bb3af997b4.1707136054%401.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.
# HG changeset patch
# User tm
# Date 1707135771 -3600
# Mon Feb 05 13:22:51 2024 +0100
# Node ID 4f5d79a9f8bb3af997b4e1add91b48025d20fad5
# Parent 4cbb14616f7eacf79cfe66b3ecd0456556dd35d6
Support mallinfo and uname on illumos
mallinfo is also available at illumos based distributions but some GLIBC lookup need to be excluded.
uname return -1 on error and non-negative value upon success. This also works for Linux which returns -1 on error.
diff -r 4cbb14616f7e -r 4f5d79a9f8bb util-src/pposix.c
--- a/util-src/pposix.c Mon Feb 05 08:05:54 2024 +0100
+++ b/util-src/pposix.c Mon Feb 05 13:22:51 2024 +0100
@@ -70,9 +70,14 @@
#include <linux/falloc.h>
#endif
-#if !defined(WITHOUT_MALLINFO) && defined(__linux__) && defined(__GLIBC__)
+#if !defined(WITHOUT_MALLINFO)
+#if ( defined(__linux__) && defined(__GLIBC__) ) || defined(__sun)
+#define WITH_MALLINFO
#include <malloc.h>
-#define WITH_MALLINFO
+#endif
+
+#elif defined(__sun)
+#include <grp.h>
#endif
#if defined(__FreeBSD__) && defined(RFPROC)
@@ -657,7 +662,7 @@
static int lc_uname(lua_State *L) {
struct utsname uname_info;
- if(uname(&uname_info) != 0) {
+ if(uname(&uname_info) < 0) {
luaL_pushfail(L);
lua_pushstring(L, strerror(errno));
return 2;
@@ -711,10 +716,15 @@
#ifdef WITH_MALLINFO
static int lc_meminfo(lua_State *L) {
+#if defined(__GLIBC__)
#if __GLIBC_PREREQ(2, 33)
struct mallinfo2 info = mallinfo2();
#define MALLINFO_T size_t
#else
+ struct mallinfo info = mallinfo();
+#define MALLINFO_T unsigned
+#endif
+#else
struct mallinfo info = mallinfo();
#define MALLINFO_T unsigned
#endif