summaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-10-20 09:35:50 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-10-20 09:35:50 -0200
commit9f4211310fcea9ebf08f4884f8665520c1b8d85f (patch)
tree7a58485c291dfc3154c6ea110c9ff65aac26172b /lbaselib.c
parent515d55683224eb78b8e8c69d3b0c7ed7a7c2076f (diff)
downloadlua-9f4211310fcea9ebf08f4884f8665520c1b8d85f.tar.gz
lua-9f4211310fcea9ebf08f4884f8665520c1b8d85f.tar.bz2
lua-9f4211310fcea9ebf08f4884f8665520c1b8d85f.zip
more precision for gc count
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 4c43b827..35622402 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.183 2005/09/16 18:22:48 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.184 2005/10/03 14:36:45 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -196,9 +196,23 @@ static int luaB_collectgarbage (lua_State *L) {
196 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, 196 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
197 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; 197 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL};
198 int o = luaL_checkoption(L, 1, "collect", opts); 198 int o = luaL_checkoption(L, 1, "collect", opts);
199 int ex = luaL_optinteger(L, 2, 0); 199 int ex = luaL_optint(L, 2, 0);
200 lua_pushinteger(L, lua_gc(L, optsnum[o], ex)); 200 int res = lua_gc(L, optsnum[o], ex);
201 return 1; 201 switch (optsnum[o]) {
202 case LUA_GCCOUNT: {
203 int b = lua_gc(L, LUA_GCCOUNTB, 0);
204 lua_pushnumber(L, ((lua_Number)res*1024 + b)/1000);
205 return 1;
206 }
207 case LUA_GCSTEP: {
208 lua_pushboolean(L, res);
209 return 1;
210 }
211 default: {
212 lua_pushnumber(L, res);
213 return 1;
214 }
215 }
202} 216}
203 217
204 218