mirror of https://github.com/rusefi/lua.git
option for garbage-collector `step'
This commit is contained in:
parent
118e471fa0
commit
345379b5ff
11
lapi.c
11
lapi.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 2.9 2004/05/14 19:25:09 roberto Exp roberto $
|
** $Id: lapi.c,v 2.10 2004/05/31 19:41:52 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -833,6 +833,15 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
|
||||||
/* GC values are expressed in Kbytes: #bytes/2^10 */
|
/* GC values are expressed in Kbytes: #bytes/2^10 */
|
||||||
return cast(int, g->nblocks >> 10);
|
return cast(int, g->nblocks >> 10);
|
||||||
}
|
}
|
||||||
|
case LUA_GCSTEP: {
|
||||||
|
lu_mem a = (cast(lu_mem, data) << 10);
|
||||||
|
if (a <= g->nblocks)
|
||||||
|
g->GCthreshold = g->nblocks - a;
|
||||||
|
else
|
||||||
|
g->GCthreshold = 0;
|
||||||
|
luaC_step(L);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
default: return -1; /* invalid option */
|
default: return -1; /* invalid option */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
lbaselib.c
21
lbaselib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbaselib.c,v 1.144 2004/05/31 18:50:30 roberto Exp roberto $
|
** $Id: lbaselib.c,v 1.145 2004/06/02 14:20:08 roberto Exp roberto $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -180,22 +180,11 @@ static int luaB_gcinfo (lua_State *L) {
|
||||||
|
|
||||||
static int luaB_collectgarbage (lua_State *L) {
|
static int luaB_collectgarbage (lua_State *L) {
|
||||||
static const char *const opts[] = {"stop", "restart", "collect", "count",
|
static const char *const opts[] = {"stop", "restart", "collect", "count",
|
||||||
NULL};
|
"step", NULL};
|
||||||
static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART,
|
static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART,
|
||||||
LUA_GCCOLLECT, LUA_GCCOUNT};
|
LUA_GCCOLLECT, LUA_GCCOUNT, LUA_GCSTEP};
|
||||||
int o;
|
int o = luaL_findstring(luaL_optstring(L, 1, "collect"), opts);
|
||||||
int ex;
|
int ex = luaL_optint(L, 2, 0);
|
||||||
#if 1
|
|
||||||
if (lua_isnumber(L, 1)) {
|
|
||||||
int v = lua_tointeger(L, 1);
|
|
||||||
lua_settop(L, 0);
|
|
||||||
if (v == 0) lua_pushstring(L, "collect");
|
|
||||||
else if (v >= 10000) lua_pushstring(L, "stop");
|
|
||||||
else lua_pushstring(L, "restart");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
o = luaL_findstring(luaL_optstring(L, 1, "collect"), opts);
|
|
||||||
ex = luaL_optint(L, 2, 0);
|
|
||||||
luaL_argcheck(L, o >= 0, 1, "invalid option");
|
luaL_argcheck(L, o >= 0, 1, "invalid option");
|
||||||
lua_pushinteger(L, lua_gc(L, optsnum[o], ex));
|
lua_pushinteger(L, lua_gc(L, optsnum[o], ex));
|
||||||
return 1;
|
return 1;
|
||||||
|
|
3
lua.h
3
lua.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lua.h,v 1.190 2004/05/31 19:41:52 roberto Exp roberto $
|
** $Id: lua.h,v 1.191 2004/06/02 17:37:03 roberto Exp roberto $
|
||||||
** Lua - An Extensible Extension Language
|
** Lua - An Extensible Extension Language
|
||||||
** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
|
** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
|
||||||
** http://www.lua.org mailto:info@lua.org
|
** http://www.lua.org mailto:info@lua.org
|
||||||
|
@ -217,6 +217,7 @@ LUA_API int lua_resume (lua_State *L, int narg);
|
||||||
#define LUA_GCRESTART 1
|
#define LUA_GCRESTART 1
|
||||||
#define LUA_GCCOLLECT 2
|
#define LUA_GCCOLLECT 2
|
||||||
#define LUA_GCCOUNT 3
|
#define LUA_GCCOUNT 3
|
||||||
|
#define LUA_GCSTEP 4
|
||||||
|
|
||||||
LUA_API int lua_gc (lua_State *L, int what, int data);
|
LUA_API int lua_gc (lua_State *L, int what, int data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue