2
0
Эх сурвалжийг харах

Removed deprecated options in 'lua_gc'

Options 'setpause' and 'setstepmul' were deprecated in Lua 5.4.
Roberto Ierusalimschy 1 жил өмнө
parent
commit
35a2fed2d1
4 өөрчлөгдсөн 10 нэмэгдсэн , 39 устгасан
  1. 3 15
      lapi.c
  2. 2 12
      lbaselib.c
  3. 3 5
      lua.h
  4. 2 7
      testes/gc.lua

+ 3 - 15
lapi.c

@@ -1163,7 +1163,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
   va_list argp;
   va_list argp;
   int res = 0;
   int res = 0;
   global_State *g = G(L);
   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 */
     return -1;  /* all options are invalid when stopped */
   lua_lock(L);
   lua_lock(L);
   va_start(argp, what);
   va_start(argp, what);
@@ -1174,7 +1174,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
     }
     }
     case LUA_GCRESTART: {
     case LUA_GCRESTART: {
       luaE_setdebt(g, 0);
       luaE_setdebt(g, 0);
-      g->gcstp = 0;  /* (bit GCSTPGC must be zero here) */
+      g->gcstp = 0;  /* (other bits must be zero here) */
       break;
       break;
     }
     }
     case LUA_GCCOLLECT: {
     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 todo = va_arg(argp, int);  /* work to be done */
       int didsomething = 0;
       int didsomething = 0;
       lu_byte oldstp = g->gcstp;
       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)
       if (todo == 0)
         todo = 1 << g->gcstepsize;  /* standard step size */
         todo = 1 << g->gcstepsize;  /* standard step size */
       while (todo >= g->GCdebt) {  /* enough to run a step? */
       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 */
         res = 1;  /* signal it */
       break;
       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: {
     case LUA_GCISRUNNING: {
       res = gcrunning(g);
       res = gcrunning(g);
       break;
       break;

+ 2 - 12
lbaselib.c

@@ -198,11 +198,9 @@ static int pushmode (lua_State *L, int oldmode) {
 
 
 static int luaB_collectgarbage (lua_State *L) {
 static int luaB_collectgarbage (lua_State *L) {
   static const char *const opts[] = {"stop", "restart", "collect",
   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,
   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)];
   int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
   switch (o) {
   switch (o) {
     case LUA_GCCOUNT: {
     case LUA_GCCOUNT: {
@@ -219,14 +217,6 @@ static int luaB_collectgarbage (lua_State *L) {
       lua_pushboolean(L, res);
       lua_pushboolean(L, res);
       return 1;
       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: {
     case LUA_GCISRUNNING: {
       int res = lua_gc(L, o);
       int res = lua_gc(L, o);
       checkvalres(res);
       checkvalres(res);

+ 3 - 5
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_GCCOUNT		3
 #define LUA_GCCOUNTB		4
 #define LUA_GCCOUNTB		4
 #define LUA_GCSTEP		5
 #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, ...);
 LUA_API int (lua_gc) (lua_State *L, int what, ...);
 
 

+ 2 - 7
testes/gc.lua

@@ -27,23 +27,18 @@ end
 
 
 -- test weird parameters to 'collectgarbage'
 -- test weird parameters to 'collectgarbage'
 do
 do
-  -- save original parameters
-  local a = collectgarbage("setpause", 200)
-  local b = collectgarbage("setstepmul", 200)
   local t = {0, 2, 10, 90, 500, 5000, 30000, 0x7ffffffe}
   local t = {0, 2, 10, 90, 500, 5000, 30000, 0x7ffffffe}
   for i = 1, #t do
   for i = 1, #t do
     local p = t[i]
     local p = t[i]
     for j = 1, #t do
     for j = 1, #t do
       local m = t[j]
       local m = t[j]
-      collectgarbage("setpause", p)
-      collectgarbage("setstepmul", m)
+      collectgarbage("incremental", p, m)
       collectgarbage("step", 0)
       collectgarbage("step", 0)
       collectgarbage("step", 10000)
       collectgarbage("step", 10000)
     end
     end
   end
   end
   -- restore original parameters
   -- restore original parameters
-  collectgarbage("setpause", a)
-  collectgarbage("setstepmul", b)
+  collectgarbage("incremental", 200, 300)
   collectgarbage()
   collectgarbage()
 end
 end