File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 1+ LUA_VER ?= 5.2
12SONAME = lua_sysctl
23BUILDDIR = build
34SOLIB = ${BUILDDIR}/sysctl.so
45DESTDIR ?= sysctl
56
67LDFLAGS += -shared -Wl,-soname,${SONAME}
7- CFLAGS += -Wall -Wextra -fPIC ` pkg-config --cflags lua-5.2 `
8+ CFLAGS += -Wall -Wextra -fPIC ` pkg-config --cflags lua-${LUA_VER} `
89
910all : ${SOLIB}
1011
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ lua version if you want to build.
2727
2828Reading:
2929```
30- > require('sysctl')
30+ > sysctl = require('sysctl')
3131> val, type = sysctl.get('kern.ostype') -- reading a string
3232> print(val)
3333FreeBSD
@@ -61,7 +61,7 @@ avm 420396
6161
6262Writting:
6363```
64- > require('sysctl')
64+ > sysctl = require('sysctl')
6565> sysctl.set('security.bsd.see_other_uids', 0)
6666```
6767
Original file line number Diff line number Diff line change 6161#include "lauxlib.h"
6262#include "lualib.h"
6363
64+ /*
65+ * lua 5.3+ define LUA_MAXINTEGER, but lua 5.2 does not. See
66+ * https://www.lua.org/manual/5.2/manual.html#lua_Integer
67+ */
68+ #ifndef LUA_MAXINTEGER
69+ #define LUA_MAXINTEGER PTRDIFF_MAX
70+ #endif
6471
6572/* NOTE: our signature of oidfmt differ from sysctl.c because we check for the
6673 buffer's size */
@@ -514,10 +521,10 @@ luaA_sysctl_get(lua_State *L)
514521 else
515522 lua_pushinteger (L , mv );
516523 } else {
517- if (intlen > sizeof ( lua_Unsigned ) )
524+ if (umv > LUA_MAXINTEGER )
518525 lua_pushnumber (L , umv );
519526 else
520- lua_pushunsigned (L , umv );
527+ lua_pushinteger (L , ( lua_Integer )( umv ) );
521528 }
522529 lua_settable (L , -3 );
523530 len -= intlen ;
You can’t perform that action at this time.
0 commit comments