diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-25 09:16:48 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-25 09:16:48 -0200 |
commit | 709b27b4564f3e4df22b973649f202fd5bb7a04a (patch) | |
tree | ad518cf8d416444c4489afe4a284aca07f37e080 /lapi.c | |
parent | dbc5451bea323e8908fcedff2a89bcf73ed5cb57 (diff) | |
download | lua-709b27b4564f3e4df22b973649f202fd5bb7a04a.tar.gz lua-709b27b4564f3e4df22b973649f202fd5bb7a04a.tar.bz2 lua-709b27b4564f3e4df22b973649f202fd5bb7a04a.zip |
ULONG_MAX>>10 may not fit into an int
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.221 2002/11/21 14:16:52 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.222 2002/11/21 15:16:04 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 | */ |
@@ -697,7 +697,8 @@ LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { | |||
697 | */ | 697 | */ |
698 | 698 | ||
699 | /* GC values are expressed in Kbytes: #bytes/2^10 */ | 699 | /* GC values are expressed in Kbytes: #bytes/2^10 */ |
700 | #define GCscale(x) (cast(int, (x)>>10)) | 700 | #define GCscalel(x) ((x)>>10) |
701 | #define GCscale(x) (cast(int, GCscalel(x))) | ||
701 | #define GCunscale(x) (cast(lu_mem, (x)<<10)) | 702 | #define GCunscale(x) (cast(lu_mem, (x)<<10)) |
702 | 703 | ||
703 | LUA_API int lua_getgcthreshold (lua_State *L) { | 704 | LUA_API int lua_getgcthreshold (lua_State *L) { |
@@ -718,7 +719,7 @@ LUA_API int lua_getgccount (lua_State *L) { | |||
718 | 719 | ||
719 | LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { | 720 | LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { |
720 | lua_lock(L); | 721 | lua_lock(L); |
721 | if (newthreshold > GCscale(ULONG_MAX)) | 722 | if (cast(lu_mem, newthreshold) > GCscalel(ULONG_MAX)) |
722 | G(L)->GCthreshold = ULONG_MAX; | 723 | G(L)->GCthreshold = ULONG_MAX; |
723 | else | 724 | else |
724 | G(L)->GCthreshold = GCunscale(newthreshold); | 725 | G(L)->GCthreshold = GCunscale(newthreshold); |