aboutsummaryrefslogtreecommitdiff
path: root/stand/common/interp_lua.c
diff options
context:
space:
mode:
Diffstat (limited to 'stand/common/interp_lua.c')
-rw-r--r--stand/common/interp_lua.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/stand/common/interp_lua.c b/stand/common/interp_lua.c
index aa759aa99ec1..2a61bb9d04af 100644
--- a/stand/common/interp_lua.c
+++ b/stand/common/interp_lua.c
@@ -96,17 +96,21 @@ static const luaL_Reg loadedlibs[] = {
{NULL, NULL}
};
+static bool preinit_done = false;
+
void
-interp_init(void)
+interp_preinit(void)
{
lua_State *luap;
struct interp_lua_softc *softc = &lua_softc;
- const char *filename;
const luaL_Reg *lib;
lua_init_md_t **fnpp;
TSENTER();
+ if (preinit_done)
+ return;
+
setenv("script.lang", "lua", 1);
LDBG("creating context");
@@ -126,6 +130,21 @@ interp_init(void)
LUA_FOREACH_SET(fnpp)
(*fnpp)(luap);
+ preinit_done = true;
+
+ TSEXIT();
+}
+
+void
+interp_init(void)
+{
+ lua_State *luap;
+ struct interp_lua_softc *softc = &lua_softc;
+ const char *filename;
+
+ TSENTER();
+
+ luap = softc->luap;
filename = getenv("loader_lua");
if (filename == NULL)
filename = LOADER_LUA;