aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/lanes.c b/src/lanes.c
index d2c95ee..332a1b8 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -2083,6 +2083,17 @@ int LANES_API luaopen_lanes_core( lua_State* L)
2083 STACK_GROW( L, 4); 2083 STACK_GROW( L, 4);
2084 STACK_CHECK( L, 0); 2084 STACK_CHECK( L, 0);
2085 2085
2086 // Prevent PUC-Lua/LuaJIT mismatch. Hopefully this works for MoonJIT too
2087 lua_getglobal( L, "jit"); // {jit?}
2088#if LUAJIT_FLAVOR() == 0
2089 if (!lua_isnil( L, -1))
2090 return luaL_error( L, "Lanes is built for PUC-Lua, don't run from LuaJIT");
2091#else
2092 if (lua_isnil( L, -1))
2093 return luaL_error( L, "Lanes is built for LuaJIT, don't run from PUC-Lua");
2094#endif
2095 lua_pop( L, 1); //
2096
2086 // Create main module interface table 2097 // Create main module interface table
2087 // we only have 1 closure, which must be called to configure Lanes 2098 // we only have 1 closure, which must be called to configure Lanes
2088 lua_newtable( L); // M 2099 lua_newtable( L); // M
@@ -2092,15 +2103,15 @@ int LANES_API luaopen_lanes_core( lua_State* L)
2092 REGISTRY_GET( L, CONFIG_REGKEY); // M LG_configure() settings 2103 REGISTRY_GET( L, CONFIG_REGKEY); // M LG_configure() settings
2093 if( !lua_isnil( L, -1)) // this is not the first require "lanes.core": call configure() immediately 2104 if( !lua_isnil( L, -1)) // this is not the first require "lanes.core": call configure() immediately
2094 { 2105 {
2095 lua_pushvalue( L, -1); // M LG_configure() settings settings 2106 lua_pushvalue( L, -1); // M LG_configure() settings settings
2096 lua_setfield( L, -4, "settings"); // M LG_configure() settings 2107 lua_setfield( L, -4, "settings"); // M LG_configure() settings
2097 lua_call( L, 1, 0); // M 2108 lua_call( L, 1, 0); // M
2098 } 2109 }
2099 else 2110 else
2100 { 2111 {
2101 // will do nothing on first invocation, as we haven't stored settings in the registry yet 2112 // will do nothing on first invocation, as we haven't stored settings in the registry yet
2102 lua_setfield( L, -3, "settings"); // M LG_configure() 2113 lua_setfield( L, -3, "settings"); // M LG_configure()
2103 lua_setfield( L, -2, "configure"); // M 2114 lua_setfield( L, -2, "configure"); // M
2104 } 2115 }
2105 2116
2106 STACK_END( L, 1); 2117 STACK_END( L, 1);