lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 4998e852eceba62738303bd2abe839680070646b
parent 65ac789565db4cbc018e8a28f3f2bc169a6d0be1
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Thu,  2 Apr 2015 18:09:56 -0300

new function 'log2' to test 'luaO_ceillog2' (if needed)

Diffstat:
Mltests.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ltests.c b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.203 2015/03/11 16:10:41 roberto Exp roberto $ +** $Id: ltests.c,v 2.204 2015/03/13 16:24:50 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -916,6 +916,13 @@ static int int2fb_aux (lua_State *L) { } +static int log2_aux (lua_State *L) { + unsigned int x = (unsigned int)luaL_checkinteger(L, 1); + lua_pushinteger(L, luaO_ceillog2(x)); + return 1; +} + + struct Aux { jmp_buf jb; const char *paniccode; lua_State *L; }; /* @@ -1508,6 +1515,7 @@ static const struct luaL_Reg tests_funcs[] = { {"getref", getref}, {"hash", hash_query}, {"int2fb", int2fb_aux}, + {"log2", log2_aux}, {"limits", get_limits}, {"listcode", listcode}, {"listk", listk},