diff --git a/src/lua/lbaselib.c b/src/lua/lbaselib.c index b3c2c6e84..bf38cba96 100644 --- a/src/lua/lbaselib.c +++ b/src/lua/lbaselib.c @@ -185,6 +185,9 @@ static int luaB_rawset (lua_State *L) { } +#ifndef LUA_REMOVE_COLLECTGARBAGE + + static int luaB_gcinfo (lua_State *L) { lua_pushinteger(L, lua_getgccount(L)); return 1; @@ -218,6 +221,9 @@ static int luaB_collectgarbage (lua_State *L) { } +#endif /* LUA_REMOVE_COLLECTGARBAGE */ + + static int luaB_type (lua_State *L) { luaL_checkany(L, 1); lua_pushstring(L, luaL_typename(L, 1)); @@ -447,12 +453,22 @@ static int luaB_newproxy (lua_State *L) { return 1; } +#ifndef LUA_REMOVE_COLLECTGARBAGE +# define COLLECTGARBAGE \ + {LSTRKEY("collectgarbage"), LFUNCVAL(luaB_collectgarbage)}, +# define GCINFO \ + {LSTRKEY("gcinfo"), LFUNCVAL(luaB_gcinfo)}, +#else +# define COLLECTGARBAGE /**/ +# define GCINFO /**/ +#endif + #define LUA_BASELIB_FUNCLIST\ {LSTRKEY("assert"), LFUNCVAL(luaB_assert)},\ - {LSTRKEY("collectgarbage"), LFUNCVAL(luaB_collectgarbage)},\ + COLLECTGARBAGE\ {LSTRKEY("dofile"), LFUNCVAL(luaB_dofile)},\ {LSTRKEY("error"), LFUNCVAL(luaB_error)},\ - {LSTRKEY("gcinfo"), LFUNCVAL(luaB_gcinfo)},\ + GCINFO\ {LSTRKEY("getfenv"), LFUNCVAL(luaB_getfenv)},\ {LSTRKEY("getmetatable"), LFUNCVAL(luaB_getmetatable)},\ {LSTRKEY("loadfile"), LFUNCVAL(luaB_loadfile)},\ diff --git a/src/lua/luaconf.h b/src/lua/luaconf.h index 997bb227d..43627dba4 100644 --- a/src/lua/luaconf.h +++ b/src/lua/luaconf.h @@ -26,6 +26,7 @@ ** which is always needed when compiling the cross-compiler @@ LUA_REMOVE_UNDUMP removes the undump mechanism, ** which is needed to be able to load compiled bytecode from *.lc files. +@@ LUA_REMOVE_COLLECTGARBAGE removes the collectgarbage() and gcinfo() functions */ #ifdef LUA_CROSS_COMPILER