MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / luaopen_bit

Function luaopen_bit

deps/lua/src/lua_bit.c:163–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161#define BAD_SAR (bsar(-8, 2) != (SBits)-2)
162
163LUALIB_API int luaopen_bit(lua_State *L)
164{
165 UBits b;
166 lua_pushnumber(L, (lua_Number)1437217655L);
167 b = barg(L, -1);
168 if (b != (UBits)1437217655L || BAD_SAR) { /* Perform a simple self-test. */
169 const char *msg = "compiled with incompatible luaconf.h";
170#ifdef LUA_NUMBER_DOUBLE
171#ifdef _WIN32
172 if (b == (UBits)1610612736L)
173 msg = "use D3DCREATE_FPU_PRESERVE with DirectX";
174#endif
175 if (b == (UBits)1127743488L)
176 msg = "not compiled with SWAPPED_DOUBLE";
177#endif
178 if (BAD_SAR)
179 msg = "arithmetic right-shift broken";
180 luaL_error(L, "bit library self-test failed (%s)", msg);
181 }
182#if LUA_VERSION_NUM < 502
183 luaL_register(L, "bit", bit_funcs);
184#else
185 luaL_newlib(L, bit_funcs);
186#endif
187 return 1;
188}
189

Callers

nothing calls this directly

Calls 3

lua_pushnumberFunction · 0.85
bargFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected