3
* Code quoted from MIT-licensed Lua 5.1.4 internals
4
* See copyright notice in lua.h
9
#endif /* __cplusplus */
16
#endif /* __cplusplus */
18
#include "luainternals.h"
21
* BEGIN COPY-PASTE FROM Lua 5.1.4 llimits.h
24
/* chars used as small naturals (so that `char' is reserved for characters) */
25
typedef unsigned char lu_byte;
28
* END COPY-PASTE FROM Lua 5.1.4 llimits.h
32
* BEGIN COPY-PASTE FROM Lua 5.1.4 lobject.c
35
int luaO_log2 (unsigned int x) {
36
static const lu_byte log_2[256] = {
37
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
38
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
39
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
40
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
41
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
42
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
43
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
44
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
47
while (x >= 256) { l += 8; x >>= 8; }
53
* END COPY-PASTE FROM Lua 5.1.4 lobject.c