diff options
| author | Mike Pall <mike> | 2015-10-01 16:26:00 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2015-10-01 16:26:00 +0200 |
| commit | 86c21bd245f7a1b1aef09999f502997f0656f127 (patch) | |
| tree | 0a835431a518e50928b3bebe27d164d201110c0a /src | |
| parent | 0b09c971c9edfdd901c9a4480423cc786bce7a94 (diff) | |
| download | luajit-86c21bd245f7a1b1aef09999f502997f0656f127.tar.gz luajit-86c21bd245f7a1b1aef09999f502997f0656f127.tar.bz2 luajit-86c21bd245f7a1b1aef09999f502997f0656f127.zip | |
Add collectgarbage("isrunning").
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib_base.c | 4 | ||||
| -rw-r--r-- | src/lj_api.c | 3 | ||||
| -rw-r--r-- | src/lua.h | 1 |
3 files changed, 6 insertions, 2 deletions
diff --git a/src/lib_base.c b/src/lib_base.c index 887fea7a..ca268b1d 100644 --- a/src/lib_base.c +++ b/src/lib_base.c | |||
| @@ -435,13 +435,13 @@ LJLIB_CF(gcinfo) | |||
| 435 | LJLIB_CF(collectgarbage) | 435 | LJLIB_CF(collectgarbage) |
| 436 | { | 436 | { |
| 437 | int opt = lj_lib_checkopt(L, 1, LUA_GCCOLLECT, /* ORDER LUA_GC* */ | 437 | int opt = lj_lib_checkopt(L, 1, LUA_GCCOLLECT, /* ORDER LUA_GC* */ |
| 438 | "\4stop\7restart\7collect\5count\1\377\4step\10setpause\12setstepmul"); | 438 | "\4stop\7restart\7collect\5count\1\377\4step\10setpause\12setstepmul\1\377\11isrunning"); |
| 439 | int32_t data = lj_lib_optint(L, 2, 0); | 439 | int32_t data = lj_lib_optint(L, 2, 0); |
| 440 | if (opt == LUA_GCCOUNT) { | 440 | if (opt == LUA_GCCOUNT) { |
| 441 | setnumV(L->top, (lua_Number)G(L)->gc.total/1024.0); | 441 | setnumV(L->top, (lua_Number)G(L)->gc.total/1024.0); |
| 442 | } else { | 442 | } else { |
| 443 | int res = lua_gc(L, opt, data); | 443 | int res = lua_gc(L, opt, data); |
| 444 | if (opt == LUA_GCSTEP) | 444 | if (opt == LUA_GCSTEP || opt == LUA_GCISRUNNING) |
| 445 | setboolV(L->top, res); | 445 | setboolV(L->top, res); |
| 446 | else | 446 | else |
| 447 | setintV(L->top, res); | 447 | setintV(L->top, res); |
diff --git a/src/lj_api.c b/src/lj_api.c index 1f09284f..042b0d9c 100644 --- a/src/lj_api.c +++ b/src/lj_api.c | |||
| @@ -1188,6 +1188,9 @@ LUA_API int lua_gc(lua_State *L, int what, int data) | |||
| 1188 | res = (int)(g->gc.stepmul); | 1188 | res = (int)(g->gc.stepmul); |
| 1189 | g->gc.stepmul = (MSize)data; | 1189 | g->gc.stepmul = (MSize)data; |
| 1190 | break; | 1190 | break; |
| 1191 | case LUA_GCISRUNNING: | ||
| 1192 | res = (g->gc.threshold != LJ_MAX_MEM); | ||
| 1193 | break; | ||
| 1191 | default: | 1194 | default: |
| 1192 | res = -1; /* Invalid option. */ | 1195 | res = -1; /* Invalid option. */ |
| 1193 | } | 1196 | } |
| @@ -226,6 +226,7 @@ LUA_API int (lua_status) (lua_State *L); | |||
| 226 | #define LUA_GCSTEP 5 | 226 | #define LUA_GCSTEP 5 |
| 227 | #define LUA_GCSETPAUSE 6 | 227 | #define LUA_GCSETPAUSE 6 |
| 228 | #define LUA_GCSETSTEPMUL 7 | 228 | #define LUA_GCSETSTEPMUL 7 |
| 229 | #define LUA_GCISRUNNING 9 | ||
| 229 | 230 | ||
| 230 | LUA_API int (lua_gc) (lua_State *L, int what, int data); | 231 | LUA_API int (lua_gc) (lua_State *L, int what, int data); |
| 231 | 232 | ||
