diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-04-28 16:58:06 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-04-28 16:58:06 -0300 |
commit | f1f8f0ca227aba8ae589c8c22bf711191e92f129 (patch) | |
tree | 306ad7a2e452741010d70e64344ae49f73d65fe4 /lapi.c | |
parent | bcc5f1406b210afdd37a508c4d44093fb80c5742 (diff) | |
download | lua-f1f8f0ca227aba8ae589c8c22bf711191e92f129.tar.gz lua-f1f8f0ca227aba8ae589c8c22bf711191e92f129.tar.bz2 lua-f1f8f0ca227aba8ae589c8c22bf711191e92f129.zip |
simpler way to check maximum gc threshold
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.234 2003/04/03 13:35:34 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.235 2003/04/07 14:36:08 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 | */ |
@@ -759,10 +759,11 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { | |||
759 | */ | 759 | */ |
760 | 760 | ||
761 | /* GC values are expressed in Kbytes: #bytes/2^10 */ | 761 | /* GC values are expressed in Kbytes: #bytes/2^10 */ |
762 | #define GCscalel(x) ((x)>>10) | 762 | #define GCscale(x) (cast(int, (x)>>10)) |
763 | #define GCscale(x) (cast(int, GCscalel(x))) | ||
764 | #define GCunscale(x) (cast(lu_mem, x)<<10) | 763 | #define GCunscale(x) (cast(lu_mem, x)<<10) |
765 | 764 | ||
765 | #define MAX_THRESHOLD (cast(lu_mem, ~0) >> 10) | ||
766 | |||
766 | LUA_API int lua_getgcthreshold (lua_State *L) { | 767 | LUA_API int lua_getgcthreshold (lua_State *L) { |
767 | int threshold; | 768 | int threshold; |
768 | lua_lock(L); | 769 | lua_lock(L); |
@@ -781,10 +782,9 @@ LUA_API int lua_getgccount (lua_State *L) { | |||
781 | 782 | ||
782 | LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { | 783 | LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { |
783 | lua_lock(L); | 784 | lua_lock(L); |
784 | if (cast(lu_mem, newthreshold) > GCscalel(MAX_LUMEM)) | 785 | if (cast(lu_mem, newthreshold) > MAX_THRESHOLD) |
785 | G(L)->GCthreshold = MAX_LUMEM; | 786 | newthreshold = cast(int, MAX_THRESHOLD); |
786 | else | 787 | G(L)->GCthreshold = GCunscale(newthreshold); |
787 | G(L)->GCthreshold = GCunscale(newthreshold); | ||
788 | luaC_checkGC(L); | 788 | luaC_checkGC(L); |
789 | lua_unlock(L); | 789 | lua_unlock(L); |
790 | } | 790 | } |