aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-11-30 15:51:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-11-30 15:51:02 -0300
commit35a2fed2d1e0b95a1bfab364707e469863517085 (patch)
treefb268c8e16b3b57a426cf9c84eb536f2958ab5c5
parent63d68bd657b7386c9c58b4439a100ea0ccbd633e (diff)
downloadlua-35a2fed2d1e0b95a1bfab364707e469863517085.tar.gz
lua-35a2fed2d1e0b95a1bfab364707e469863517085.tar.bz2
lua-35a2fed2d1e0b95a1bfab364707e469863517085.zip
Removed deprecated options in 'lua_gc'
Options 'setpause' and 'setstepmul' were deprecated in Lua 5.4.
Diffstat (limited to '')
-rw-r--r--lapi.c18
-rw-r--r--lbaselib.c14
-rw-r--r--lua.h8
-rw-r--r--testes/gc.lua9
4 files changed, 10 insertions, 39 deletions
diff --git a/lapi.c b/lapi.c
index 2aaa6505..93695144 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1163,7 +1163,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
1163 va_list argp; 1163 va_list argp;
1164 int res = 0; 1164 int res = 0;
1165 global_State *g = G(L); 1165 global_State *g = G(L);
1166 if (g->gcstp & GCSTPGC) /* internal stop? */ 1166 if (g->gcstp & (GCSTPGC | GCSTPCLS)) /* internal stop? */
1167 return -1; /* all options are invalid when stopped */ 1167 return -1; /* all options are invalid when stopped */
1168 lua_lock(L); 1168 lua_lock(L);
1169 va_start(argp, what); 1169 va_start(argp, what);
@@ -1174,7 +1174,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
1174 } 1174 }
1175 case LUA_GCRESTART: { 1175 case LUA_GCRESTART: {
1176 luaE_setdebt(g, 0); 1176 luaE_setdebt(g, 0);
1177 g->gcstp = 0; /* (bit GCSTPGC must be zero here) */ 1177 g->gcstp = 0; /* (other bits must be zero here) */
1178 break; 1178 break;
1179 } 1179 }
1180 case LUA_GCCOLLECT: { 1180 case LUA_GCCOLLECT: {
@@ -1194,7 +1194,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
1194 int todo = va_arg(argp, int); /* work to be done */ 1194 int todo = va_arg(argp, int); /* work to be done */
1195 int didsomething = 0; 1195 int didsomething = 0;
1196 lu_byte oldstp = g->gcstp; 1196 lu_byte oldstp = g->gcstp;
1197 g->gcstp = 0; /* allow GC to run (bit GCSTPGC must be zero here) */ 1197 g->gcstp = 0; /* allow GC to run (other bits must be zero here) */
1198 if (todo == 0) 1198 if (todo == 0)
1199 todo = 1 << g->gcstepsize; /* standard step size */ 1199 todo = 1 << g->gcstepsize; /* standard step size */
1200 while (todo >= g->GCdebt) { /* enough to run a step? */ 1200 while (todo >= g->GCdebt) { /* enough to run a step? */
@@ -1213,18 +1213,6 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
1213 res = 1; /* signal it */ 1213 res = 1; /* signal it */
1214 break; 1214 break;
1215 } 1215 }
1216 case LUA_GCSETPAUSE: {
1217 unsigned int data = va_arg(argp, unsigned int);
1218 res = applygcparam(g, gcpause, 100);
1219 setgcparam(g, gcpause, data);
1220 break;
1221 }
1222 case LUA_GCSETSTEPMUL: {
1223 unsigned int data = va_arg(argp, unsigned int);
1224 res = applygcparam(g, gcstepmul, 100);
1225 setgcparam(g, gcstepmul, data);
1226 break;
1227 }
1228 case LUA_GCISRUNNING: { 1216 case LUA_GCISRUNNING: {
1229 res = gcrunning(g); 1217 res = gcrunning(g);
1230 break; 1218 break;
diff --git a/lbaselib.c b/lbaselib.c
index 5a23c937..54a6c02d 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -198,11 +198,9 @@ static int pushmode (lua_State *L, int oldmode) {
198 198
199static int luaB_collectgarbage (lua_State *L) { 199static int luaB_collectgarbage (lua_State *L) {
200 static const char *const opts[] = {"stop", "restart", "collect", 200 static const char *const opts[] = {"stop", "restart", "collect",
201 "count", "step", "setpause", "setstepmul", 201 "count", "step", "isrunning", "generational", "incremental", NULL};
202 "isrunning", "generational", "incremental", NULL};
203 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, 202 static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
204 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, 203 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
205 LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
206 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; 204 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
207 switch (o) { 205 switch (o) {
208 case LUA_GCCOUNT: { 206 case LUA_GCCOUNT: {
@@ -219,14 +217,6 @@ static int luaB_collectgarbage (lua_State *L) {
219 lua_pushboolean(L, res); 217 lua_pushboolean(L, res);
220 return 1; 218 return 1;
221 } 219 }
222 case LUA_GCSETPAUSE:
223 case LUA_GCSETSTEPMUL: {
224 int p = (int)luaL_optinteger(L, 2, 0);
225 int previous = lua_gc(L, o, p);
226 checkvalres(previous);
227 lua_pushinteger(L, previous);
228 return 1;
229 }
230 case LUA_GCISRUNNING: { 220 case LUA_GCISRUNNING: {
231 int res = lua_gc(L, o); 221 int res = lua_gc(L, o);
232 checkvalres(res); 222 checkvalres(res);
diff --git a/lua.h b/lua.h
index ca8d06fe..32768561 100644
--- a/lua.h
+++ b/lua.h
@@ -334,11 +334,9 @@ LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont);
334#define LUA_GCCOUNT 3 334#define LUA_GCCOUNT 3
335#define LUA_GCCOUNTB 4 335#define LUA_GCCOUNTB 4
336#define LUA_GCSTEP 5 336#define LUA_GCSTEP 5
337#define LUA_GCSETPAUSE 6 337#define LUA_GCISRUNNING 6
338#define LUA_GCSETSTEPMUL 7 338#define LUA_GCGEN 7
339#define LUA_GCISRUNNING 9 339#define LUA_GCINC 8
340#define LUA_GCGEN 10
341#define LUA_GCINC 11
342 340
343LUA_API int (lua_gc) (lua_State *L, int what, ...); 341LUA_API int (lua_gc) (lua_State *L, int what, ...);
344 342
diff --git a/testes/gc.lua b/testes/gc.lua
index 3c928d7c..4cf7d556 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -27,23 +27,18 @@ end
27 27
28-- test weird parameters to 'collectgarbage' 28-- test weird parameters to 'collectgarbage'
29do 29do
30 -- save original parameters
31 local a = collectgarbage("setpause", 200)
32 local b = collectgarbage("setstepmul", 200)
33 local t = {0, 2, 10, 90, 500, 5000, 30000, 0x7ffffffe} 30 local t = {0, 2, 10, 90, 500, 5000, 30000, 0x7ffffffe}
34 for i = 1, #t do 31 for i = 1, #t do
35 local p = t[i] 32 local p = t[i]
36 for j = 1, #t do 33 for j = 1, #t do
37 local m = t[j] 34 local m = t[j]
38 collectgarbage("setpause", p) 35 collectgarbage("incremental", p, m)
39 collectgarbage("setstepmul", m)
40 collectgarbage("step", 0) 36 collectgarbage("step", 0)
41 collectgarbage("step", 10000) 37 collectgarbage("step", 10000)
42 end 38 end
43 end 39 end
44 -- restore original parameters 40 -- restore original parameters
45 collectgarbage("setpause", a) 41 collectgarbage("incremental", 200, 300)
46 collectgarbage("setstepmul", b)
47 collectgarbage() 42 collectgarbage()
48end 43end
49 44