aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-16 12:31:13 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-16 12:31:13 +0100
commit35818aec2c5f6e70423fa2954fc9a344b5fe56f0 (patch)
tree27280486b94db70a29eaed4f1c4d4fb048a8a6ec /src
parent6836dfd2b3af64bd29e9992b2dc21ebfd83ed539 (diff)
downloadrspamd-35818aec2c5f6e70423fa2954fc9a344b5fe56f0.tar.gz
rspamd-35818aec2c5f6e70423fa2954fc9a344b5fe56f0.zip
[Minor] Lua core: Add some missing compat functions
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_common.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index 507925e80..265775835 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -40,6 +40,28 @@ luaL_register (lua_State *L, const gchar *name, const struct luaL_reg *methods)
}
#endif
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
+static inline int lua_absindex (lua_State *L, int i) {
+ if (i < 0 && i > LUA_REGISTRYINDEX)
+ i += lua_gettop(L) + 1;
+ return i;
+}
+static inline int lua_rawgetp (lua_State *L, int i, const void *p) {
+ int abs_i = lua_absindex(L, i);
+ lua_pushlightuserdata(L, (void*)p);
+ lua_rawget(L, abs_i);
+ return lua_type(L, -1);
+}
+
+static inline void lua_rawsetp (lua_State *L, int i, const void *p) {
+ int abs_i = lua_absindex(L, i);
+ luaL_checkstack(L, 1, "not enough stack slots");
+ lua_pushlightuserdata(L, (void*)p);
+ lua_insert(L, -2);
+ lua_rawset(L, abs_i);
+}
+#endif
+
/* Interface definitions */
#define LUA_FUNCTION_DEF(class, name) static int lua_ ## class ## _ ## name ( \
lua_State * L)