MCPcopy Create free account
hub / github.com/defold/defold / luaopen_bit

Function luaopen_bit

engine/script/src/bitop/bitop.c:161–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

InitializeBitopFunction · 0.85

Calls 3

lua_pushnumberFunction · 0.85
bargFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected