commit 35a2fed2d1e0b95a1bfab364707e469863517085
parent 63d68bd657b7386c9c58b4439a100ea0ccbd633e
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 30 Nov 2023 15:50:35 -0300
Removed deprecated options in 'lua_gc'
Options 'setpause' and 'setstepmul' were deprecated in Lua 5.4.
Diffstat:
4 files changed, 10 insertions(+), 39 deletions(-)
diff --git a/lapi.c b/lapi.c
@@ -1163,7 +1163,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);
@@ -1174,7 +1174,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: {
@@ -1194,7 +1194,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? */
@@ -1213,18 +1213,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/lbaselib.c b/lbaselib.c
@@ -198,11 +198,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};
+ "count", "step", "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};
+ LUA_GCCOUNT, LUA_GCSTEP, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
switch (o) {
case LUA_GCCOUNT: {
@@ -219,14 +217,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/lua.h b/lua.h
@@ -334,11 +334,9 @@ LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont);
#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
@@ -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