diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-04-02 18:10:21 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-04-02 18:10:21 -0300 |
commit | 4998e852eceba62738303bd2abe839680070646b (patch) | |
tree | 399e89638d752162d3f60101a3496b03f467c86d | |
parent | 65ac789565db4cbc018e8a28f3f2bc169a6d0be1 (diff) | |
download | lua-4998e852eceba62738303bd2abe839680070646b.tar.gz lua-4998e852eceba62738303bd2abe839680070646b.tar.bz2 lua-4998e852eceba62738303bd2abe839680070646b.zip |
new function 'log2' to test 'luaO_ceillog2' (if needed)
-rw-r--r-- | ltests.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.203 2015/03/11 16:10:41 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.204 2015/03/13 16:24:50 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -916,6 +916,13 @@ static int int2fb_aux (lua_State *L) { | |||
916 | } | 916 | } |
917 | 917 | ||
918 | 918 | ||
919 | static int log2_aux (lua_State *L) { | ||
920 | unsigned int x = (unsigned int)luaL_checkinteger(L, 1); | ||
921 | lua_pushinteger(L, luaO_ceillog2(x)); | ||
922 | return 1; | ||
923 | } | ||
924 | |||
925 | |||
919 | struct Aux { jmp_buf jb; const char *paniccode; lua_State *L; }; | 926 | struct Aux { jmp_buf jb; const char *paniccode; lua_State *L; }; |
920 | 927 | ||
921 | /* | 928 | /* |
@@ -1508,6 +1515,7 @@ static const struct luaL_Reg tests_funcs[] = { | |||
1508 | {"getref", getref}, | 1515 | {"getref", getref}, |
1509 | {"hash", hash_query}, | 1516 | {"hash", hash_query}, |
1510 | {"int2fb", int2fb_aux}, | 1517 | {"int2fb", int2fb_aux}, |
1518 | {"log2", log2_aux}, | ||
1511 | {"limits", get_limits}, | 1519 | {"limits", get_limits}, |
1512 | {"listcode", listcode}, | 1520 | {"listcode", listcode}, |
1513 | {"listk", listk}, | 1521 | {"listk", listk}, |