File tree 3 files changed +13
-5
lines changed
3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change
1
+ LUA_VER ?= 5.2
1
2
SONAME = lua_sysctl
2
3
BUILDDIR = build
3
4
SOLIB = ${BUILDDIR}/sysctl.so
4
5
DESTDIR ?= sysctl
5
6
6
7
LDFLAGS += -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} `
8
9
9
10
all : ${SOLIB}
10
11
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ lua version if you want to build.
27
27
28
28
Reading:
29
29
```
30
- > require('sysctl')
30
+ > sysctl = require('sysctl')
31
31
> val, type = sysctl.get('kern.ostype') -- reading a string
32
32
> print(val)
33
33
FreeBSD
@@ -61,7 +61,7 @@ avm 420396
61
61
62
62
Writting:
63
63
```
64
- > require('sysctl')
64
+ > sysctl = require('sysctl')
65
65
> sysctl.set('security.bsd.see_other_uids', 0)
66
66
```
67
67
Original file line number Diff line number Diff line change 61
61
#include "lauxlib.h"
62
62
#include "lualib.h"
63
63
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
64
71
65
72
/* NOTE: our signature of oidfmt differ from sysctl.c because we check for the
66
73
buffer's size */
@@ -514,10 +521,10 @@ luaA_sysctl_get(lua_State *L)
514
521
else
515
522
lua_pushinteger (L , mv );
516
523
} else {
517
- if (intlen > sizeof ( lua_Unsigned ) )
524
+ if (umv > LUA_MAXINTEGER )
518
525
lua_pushnumber (L , umv );
519
526
else
520
- lua_pushunsigned (L , umv );
527
+ lua_pushinteger (L , ( lua_Integer )( umv ) );
521
528
}
522
529
lua_settable (L , -3 );
523
530
len -= intlen ;
You can’t perform that action at this time.
0 commit comments