diff options
-rw-r--r-- | lapi.c | 6 | ||||
-rw-r--r-- | lbaselib.c | 14 |
2 files changed, 14 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.281 2018/01/28 15:13:26 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.282 2018/01/29 16:21:35 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -1121,6 +1121,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { | |||
1121 | break; | 1121 | break; |
1122 | } | 1122 | } |
1123 | case LUA_GCGEN: { | 1123 | case LUA_GCGEN: { |
1124 | int oldmode = g->gckind; | ||
1124 | int minormul = va_arg(argp, int); | 1125 | int minormul = va_arg(argp, int); |
1125 | int majormul = va_arg(argp, int); | 1126 | int majormul = va_arg(argp, int); |
1126 | if (minormul != 0) | 1127 | if (minormul != 0) |
@@ -1128,9 +1129,11 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { | |||
1128 | if (majormul != 0) | 1129 | if (majormul != 0) |
1129 | setgcparam(g->genmajormul, majormul); | 1130 | setgcparam(g->genmajormul, majormul); |
1130 | luaC_changemode(L, KGC_GEN); | 1131 | luaC_changemode(L, KGC_GEN); |
1132 | res = (oldmode == KGC_GEN) ? LUA_GCGEN : LUA_GCINC; | ||
1131 | break; | 1133 | break; |
1132 | } | 1134 | } |
1133 | case LUA_GCINC: { | 1135 | case LUA_GCINC: { |
1136 | int oldmode = g->gckind; | ||
1134 | int pause = va_arg(argp, int); | 1137 | int pause = va_arg(argp, int); |
1135 | int stepmul = va_arg(argp, int); | 1138 | int stepmul = va_arg(argp, int); |
1136 | int stepsize = va_arg(argp, int); | 1139 | int stepsize = va_arg(argp, int); |
@@ -1141,6 +1144,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { | |||
1141 | if (stepsize != 0) | 1144 | if (stepsize != 0) |
1142 | g->gcstepsize = stepsize; | 1145 | g->gcstepsize = stepsize; |
1143 | luaC_changemode(L, KGC_INC); | 1146 | luaC_changemode(L, KGC_INC); |
1147 | res = (oldmode == KGC_GEN) ? LUA_GCGEN : LUA_GCINC; | ||
1144 | break; | 1148 | break; |
1145 | } | 1149 | } |
1146 | default: res = -1; /* invalid option */ | 1150 | default: res = -1; /* invalid option */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.317 2017/06/27 18:32:49 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.318 2017/11/16 13:19:06 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -170,6 +170,12 @@ static int luaB_rawset (lua_State *L) { | |||
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | static int pushmode (lua_State *L, int oldmode) { | ||
174 | lua_pushstring(L, (oldmode == LUA_GCINC) ? "incremental" : "generational"); | ||
175 | return 1; | ||
176 | } | ||
177 | |||
178 | |||
173 | static int luaB_collectgarbage (lua_State *L) { | 179 | static int luaB_collectgarbage (lua_State *L) { |
174 | static const char *const opts[] = {"stop", "restart", "collect", | 180 | static const char *const opts[] = {"stop", "restart", "collect", |
175 | "count", "step", "setpause", "setstepmul", | 181 | "count", "step", "setpause", "setstepmul", |
@@ -206,15 +212,13 @@ static int luaB_collectgarbage (lua_State *L) { | |||
206 | case LUA_GCGEN: { | 212 | case LUA_GCGEN: { |
207 | int minormul = (int)luaL_optinteger(L, 2, 0); | 213 | int minormul = (int)luaL_optinteger(L, 2, 0); |
208 | int majormul = (int)luaL_optinteger(L, 3, 0); | 214 | int majormul = (int)luaL_optinteger(L, 3, 0); |
209 | lua_gc(L, o, minormul, majormul); | 215 | return pushmode(L, lua_gc(L, o, minormul, majormul)); |
210 | return 0; | ||
211 | } | 216 | } |
212 | case LUA_GCINC: { | 217 | case LUA_GCINC: { |
213 | int pause = (int)luaL_optinteger(L, 2, 0); | 218 | int pause = (int)luaL_optinteger(L, 2, 0); |
214 | int stepmul = (int)luaL_optinteger(L, 3, 0); | 219 | int stepmul = (int)luaL_optinteger(L, 3, 0); |
215 | int stepsize = (int)luaL_optinteger(L, 4, 0); | 220 | int stepsize = (int)luaL_optinteger(L, 4, 0); |
216 | lua_gc(L, o, pause, stepmul, stepsize); | 221 | return pushmode(L, lua_gc(L, o, pause, stepmul, stepsize)); |
217 | return 0; | ||
218 | } | 222 | } |
219 | default: { | 223 | default: { |
220 | int res = lua_gc(L, o); | 224 | int res = lua_gc(L, o); |