From f1f8f0ca227aba8ae589c8c22bf711191e92f129 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 28 Apr 2003 16:58:06 -0300 Subject: [PATCH] simpler way to check maximum gc threshold --- lapi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lapi.c b/lapi.c index 78a9dd3b..a8c34ed1 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 1.234 2003/04/03 13:35:34 roberto Exp roberto $ +** $Id: lapi.c,v 1.235 2003/04/07 14:36:08 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -759,10 +759,11 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { */ /* GC values are expressed in Kbytes: #bytes/2^10 */ -#define GCscalel(x) ((x)>>10) -#define GCscale(x) (cast(int, GCscalel(x))) +#define GCscale(x) (cast(int, (x)>>10)) #define GCunscale(x) (cast(lu_mem, x)<<10) +#define MAX_THRESHOLD (cast(lu_mem, ~0) >> 10) + LUA_API int lua_getgcthreshold (lua_State *L) { int threshold; lua_lock(L); @@ -781,10 +782,9 @@ LUA_API int lua_getgccount (lua_State *L) { LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { lua_lock(L); - if (cast(lu_mem, newthreshold) > GCscalel(MAX_LUMEM)) - G(L)->GCthreshold = MAX_LUMEM; - else - G(L)->GCthreshold = GCunscale(newthreshold); + if (cast(lu_mem, newthreshold) > MAX_THRESHOLD) + newthreshold = cast(int, MAX_THRESHOLD); + G(L)->GCthreshold = GCunscale(newthreshold); luaC_checkGC(L); lua_unlock(L); }