From 4998e852eceba62738303bd2abe839680070646b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 2 Apr 2015 18:10:21 -0300 Subject: new function 'log2' to test 'luaO_ceillog2' (if needed) --- ltests.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ltests.c b/ltests.c index 80bfa5a6..d1f63f1b 100644 --- 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}, -- cgit v1.2.3-55-g6feb