diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-20 09:35:50 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-20 09:35:50 -0200 |
commit | 9f4211310fcea9ebf08f4884f8665520c1b8d85f (patch) | |
tree | 7a58485c291dfc3154c6ea110c9ff65aac26172b | |
parent | 515d55683224eb78b8e8c69d3b0c7ed7a7c2076f (diff) | |
download | lua-9f4211310fcea9ebf08f4884f8665520c1b8d85f.tar.gz lua-9f4211310fcea9ebf08f4884f8665520c1b8d85f.tar.bz2 lua-9f4211310fcea9ebf08f4884f8665520c1b8d85f.zip |
more precision for gc count
-rw-r--r-- | lapi.c | 6 | ||||
-rw-r--r-- | lbaselib.c | 22 | ||||
-rw-r--r-- | lua.h | 9 |
3 files changed, 28 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.49 2005/09/14 17:44:48 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.50 2005/09/20 17:55:10 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -913,6 +913,10 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { | |||
913 | res = cast(int, g->totalbytes >> 10); | 913 | res = cast(int, g->totalbytes >> 10); |
914 | break; | 914 | break; |
915 | } | 915 | } |
916 | case LUA_GCCOUNTB: { | ||
917 | res = cast(int, g->totalbytes & 0x3ff); | ||
918 | break; | ||
919 | } | ||
916 | case LUA_GCSTEP: { | 920 | case LUA_GCSTEP: { |
917 | lu_mem a = (cast(lu_mem, data) << 10); | 921 | lu_mem a = (cast(lu_mem, data) << 10); |
918 | if (a <= g->totalbytes) | 922 | if (a <= g->totalbytes) |
@@ -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 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.212 2005/08/25 20:02:08 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.213 2005/09/20 17:55:10 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
5 | ** See Copyright Notice at the end of this file | 5 | ** See Copyright Notice at the end of this file |
@@ -221,9 +221,10 @@ LUA_API int (lua_status) (lua_State *L); | |||
221 | #define LUA_GCRESTART 1 | 221 | #define LUA_GCRESTART 1 |
222 | #define LUA_GCCOLLECT 2 | 222 | #define LUA_GCCOLLECT 2 |
223 | #define LUA_GCCOUNT 3 | 223 | #define LUA_GCCOUNT 3 |
224 | #define LUA_GCSTEP 4 | 224 | #define LUA_GCCOUNTB 4 |
225 | #define LUA_GCSETPAUSE 5 | 225 | #define LUA_GCSTEP 5 |
226 | #define LUA_GCSETSTEPMUL 6 | 226 | #define LUA_GCSETPAUSE 6 |
227 | #define LUA_GCSETSTEPMUL 7 | ||
227 | 228 | ||
228 | LUA_API int (lua_gc) (lua_State *L, int what, int data); | 229 | LUA_API int (lua_gc) (lua_State *L, int what, int data); |
229 | 230 | ||