diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-11-30 15:51:02 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-11-30 15:51:02 -0300 |
commit | 35a2fed2d1e0b95a1bfab364707e469863517085 (patch) | |
tree | fb268c8e16b3b57a426cf9c84eb536f2958ab5c5 | |
parent | 63d68bd657b7386c9c58b4439a100ea0ccbd633e (diff) | |
download | lua-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.c | 18 | ||||
-rw-r--r-- | lbaselib.c | 14 | ||||
-rw-r--r-- | lua.h | 8 | ||||
-rw-r--r-- | testes/gc.lua | 9 |
4 files changed, 10 insertions, 39 deletions
@@ -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; |
@@ -198,11 +198,9 @@ static int pushmode (lua_State *L, int oldmode) { | |||
198 | 198 | ||
199 | static int luaB_collectgarbage (lua_State *L) { | 199 | static 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); |
@@ -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 | ||
343 | LUA_API int (lua_gc) (lua_State *L, int what, ...); | 341 | LUA_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' |
29 | do | 29 | do |
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() |
48 | end | 43 | end |
49 | 44 | ||