Skip to content

Commit

Permalink
Add luaconf.h LUA_REMOVE_COLLECTGARBAGE to drop collectgarbage and gc…
Browse files Browse the repository at this point in the history
…info

For systems with a lack of program space
  • Loading branch information
martinwguy committed May 13, 2013
1 parent e3196ff commit b9b98c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/lua/lbaselib.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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)},\
Expand Down
1 change: 1 addition & 0 deletions src/lua/luaconf.h
Expand Up @@ -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
Expand Down

0 comments on commit b9b98c9

Please sign in to comment.