From 9bd9d9fe5f0e21d5253fceafa3ef73b3c096a1d2 Mon Sep 17 00:00:00 2001 From: Sainan Date: Wed, 7 Feb 2024 02:19:18 +0100 Subject: [PATCH] 35a2fed2d1e0b95a1bfab364707e469863517085 --- src/lapi.cpp | 18 +++--------------- src/lbaselib.cpp | 16 +++------------- src/lua.h | 8 +++----- testes/gc.lua | 9 ++------- 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/lapi.cpp b/src/lapi.cpp index ae47e0d87e..43c58e183e 100644 --- a/src/lapi.cpp +++ b/src/lapi.cpp @@ -1283,7 +1283,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { va_list argp; int res = 0; global_State *g = G(L); - if (g->gcstp & GCSTPGC) /* internal stop? */ + if (g->gcstp & (GCSTPGC | GCSTPCLS)) /* internal stop? */ return -1; /* all options are invalid when stopped */ lua_lock(L); va_start(argp, what); @@ -1294,7 +1294,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { } case LUA_GCRESTART: { luaE_setdebt(g, 0); - g->gcstp = 0; /* (bit GCSTPGC must be zero here) */ + g->gcstp = 0; /* (other bits must be zero here) */ break; } case LUA_GCCOLLECT: { @@ -1314,7 +1314,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { int todo = va_arg(argp, int); /* work to be done */ int didsomething = 0; lu_byte oldstp = g->gcstp; - g->gcstp = 0; /* allow GC to run (bit GCSTPGC must be zero here) */ + g->gcstp = 0; /* allow GC to run (other bits must be zero here) */ if (todo == 0) todo = 1 << g->gcstepsize; /* standard step size */ while (todo >= g->GCdebt) { /* enough to run a step? */ @@ -1333,18 +1333,6 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { res = 1; /* signal it */ break; } - case LUA_GCSETPAUSE: { - unsigned int data = va_arg(argp, unsigned int); - res = applygcparam(g, gcpause, 100); - setgcparam(g, gcpause, data); - break; - } - case LUA_GCSETSTEPMUL: { - unsigned int data = va_arg(argp, unsigned int); - res = applygcparam(g, gcstepmul, 100); - setgcparam(g, gcstepmul, data); - break; - } case LUA_GCISRUNNING: { res = gcrunning(g); break; diff --git a/src/lbaselib.cpp b/src/lbaselib.cpp index 570cccf4a5..8d12e1d4bb 100644 --- a/src/lbaselib.cpp +++ b/src/lbaselib.cpp @@ -248,11 +248,9 @@ static int pushmode (lua_State *L, int oldmode) { static int luaB_collectgarbage (lua_State *L) { static const char *const opts[] = {"stop", "restart", "collect", - "count", "step", "setpause", "setstepmul", - "isrunning", "generational", "incremental", NULL}; - static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, - LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, - LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC}; + "count", "step", "isrunning", "generational", "incremental", NULL}; + static const int optsnum[] = { LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC }; int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; switch (o) { case LUA_GCCOUNT: { @@ -269,14 +267,6 @@ static int luaB_collectgarbage (lua_State *L) { lua_pushboolean(L, res); return 1; } - case LUA_GCSETPAUSE: - case LUA_GCSETSTEPMUL: { - int p = (int)luaL_optinteger(L, 2, 0); - int previous = lua_gc(L, o, p); - checkvalres(previous); - lua_pushinteger(L, previous); - return 1; - } case LUA_GCISRUNNING: { int res = lua_gc(L, o); checkvalres(res); diff --git a/src/lua.h b/src/lua.h index 4a45e11b45..861d3a8ada 100644 --- a/src/lua.h +++ b/src/lua.h @@ -350,11 +350,9 @@ PLUTO_API void (pluto_warning) (lua_State *L, const char *msg); #define LUA_GCCOUNT 3 #define LUA_GCCOUNTB 4 #define LUA_GCSTEP 5 -#define LUA_GCSETPAUSE 6 -#define LUA_GCSETSTEPMUL 7 -#define LUA_GCISRUNNING 9 -#define LUA_GCGEN 10 -#define LUA_GCINC 11 +#define LUA_GCISRUNNING 6 +#define LUA_GCGEN 7 +#define LUA_GCINC 8 LUA_API int (lua_gc) (lua_State *L, int what, ...); diff --git a/testes/gc.lua b/testes/gc.lua index 3c928d7c15..4cf7d556c7 100644 --- a/testes/gc.lua +++ b/testes/gc.lua @@ -27,23 +27,18 @@ end -- test weird parameters to 'collectgarbage' do - -- save original parameters - local a = collectgarbage("setpause", 200) - local b = collectgarbage("setstepmul", 200) local t = {0, 2, 10, 90, 500, 5000, 30000, 0x7ffffffe} for i = 1, #t do local p = t[i] for j = 1, #t do local m = t[j] - collectgarbage("setpause", p) - collectgarbage("setstepmul", m) + collectgarbage("incremental", p, m) collectgarbage("step", 0) collectgarbage("step", 10000) end end -- restore original parameters - collectgarbage("setpause", a) - collectgarbage("setstepmul", b) + collectgarbage("incremental", 200, 300) collectgarbage() end