17#if !defined(LUA_NBITS)
22#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1))
25#define trim(x) ((x) & ALLONES)
29#define mask(n) (~((ALLONES << 1) << ((n) - 1)))
39 for (i = 1; i <= n; i++)
62 for (i = 1; i <= n; i++)
72 for (i = 1; i <= n; i++)
80 b_uint r = ~luaL_checkunsigned(L, 1);
161 luaL_error(L,
"trying to access non-existent bits");
171 r = (r >> f) &
mask(w);
184 r = (r & ~(m << f)) | (v << f);
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API int lua_gettop(lua_State *L)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
#define luaL_optint(L, n, d)
#define luaL_checkint(L, n)
#define luaL_argcheck(L, cond, numarg, extramsg)
LUA_API void lua_pushunsigned(lua_State *L, lua_Unsigned u)
LUALIB_API lua_Unsigned luaL_checkunsigned(lua_State *L, int narg)
#define luaL_newlib(L, l)
static int b_rrot(lua_State *L)
LUAMOD_API int luaopen_bit32(lua_State *L)
static int b_xor(lua_State *L)
static int b_replace(lua_State *L)
static int b_or(lua_State *L)
static int b_and(lua_State *L)
static int b_extract(lua_State *L)
static int b_shift(lua_State *L, b_uint r, int i)
static int fieldargs(lua_State *L, int farg, int *width)
static int b_rshift(lua_State *L)
static int b_not(lua_State *L)
static int b_lshift(lua_State *L)
static const luaL_Reg bitlib[]
static int b_lrot(lua_State *L)
static int b_test(lua_State *L)
static int b_arshift(lua_State *L)
static int b_rot(lua_State *L, int i)
static b_uint andaux(lua_State *L)
LUA_UNSIGNED lua_Unsigned