|
@@ -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
|
|
** Lua API
|
|
** See Copyright Notice in lua.h
|
|
** 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 */
|
|
/* 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 GCunscale(x) (cast(lu_mem, x)<<10)
|
|
|
|
|
|
|
|
+#define MAX_THRESHOLD (cast(lu_mem, ~0) >> 10)
|
|
|
|
+
|
|
LUA_API int lua_getgcthreshold (lua_State *L) {
|
|
LUA_API int lua_getgcthreshold (lua_State *L) {
|
|
int threshold;
|
|
int threshold;
|
|
lua_lock(L);
|
|
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_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
|
|
lua_lock(L);
|
|
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);
|
|
luaC_checkGC(L);
|
|
lua_unlock(L);
|
|
lua_unlock(L);
|
|
}
|
|
}
|