There is a function provided by Windows API to get all system information.
--
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/8c6122068cb6272a5791.1677276754%40EI08_MatisseX.
# HG changeset patch
# User Vitaly Orekhov
# Date 1677276708 -10800
# Sat Feb 25 01:11:48 2023 +0300
# Node ID 8c6122068cb6272a5791060389c42844c56caf8d
# Parent 3b390a8cc12cbf946ba45d3cc7c15d6e891eb9db
util.ringbuffer: Detect page size by querying GetSystemInfo() on Windows
There is a function provided by Windows API to get all system information.
diff -r 3b390a8cc12c -r 8c6122068cb6 util-src/ringbuffer.c
--- a/util-src/ringbuffer.c Sat Feb 25 00:56:38 2023 +0300
+++ b/util-src/ringbuffer.c Sat Feb 25 01:11:48 2023 +0300
@@ -1,6 +1,11 @@
#include <stdlib.h>
+#ifndef _WIN32
#include <unistd.h>
+#else
+#include <windows.h>
+#include <sysinfoapi.h>
+#endif
#include <string.h>
#include <lua.h>
@@ -298,7 +303,13 @@
}
static int rb_new(lua_State *L) {
+#ifndef _WIN32
lua_Integer size = luaL_optinteger(L, 1, sysconf(_SC_PAGESIZE));
+#else
+ SYSTEM_INFO sysInfo;
+ GetSystemInfo(&sysInfo);
+ lua_Integer size = luaL_optinteger(L, 1, sysInfo.dwPageSize);
+#endif
luaL_argcheck(L, size > 0, 1, "positive integer expected");
ringbuffer *b = lua_newuserdata(L, sizeof(ringbuffer) + size);