MCPcopy Create free account
hub / github.com/TASEmulators/fceux / luabitop_validate

Function luabitop_validate

src/lua-engine.cpp:5866–5887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5864#define BAD_SAR (bsar(-8, 2) != (SBits)-2)
5865
5866bool luabitop_validate(lua_State *L) // originally named as luaopen_bit
5867{
5868 UBits b;
5869 lua_pushnumber(L, (lua_Number)1437217655L);
5870 b = barg(L, -1);
5871 if (b != (UBits)1437217655L || BAD_SAR) { /* Perform a simple self-test. */
5872 const char *msg = "compiled with incompatible luaconf.h";
5873#ifdef LUA_NUMBER_DOUBLE
5874#ifdef __WIN_DRIVER__
5875 if (b == (UBits)1610612736L)
5876 msg = "use D3DCREATE_FPU_PRESERVE with DirectX";
5877#endif
5878 if (b == (UBits)1127743488L)
5879 msg = "not compiled with SWAPPED_DOUBLE";
5880#endif
5881 if (BAD_SAR)
5882 msg = "arithmetic right-shift broken";
5883 luaL_error(L, "bit library self-test failed (%s)", msg);
5884 return false;
5885 }
5886 return true;
5887}
5888
5889// LuaBitOp ends here
5890

Callers 1

FCEU_LoadLuaCodeFunction · 0.85

Calls 3

lua_pushnumberFunction · 0.85
bargFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected