#define linit_c
#define LUA_LIB
#include "lprefix.h"
#include <stddef.h>
#include <stdlib.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include "lposix.h"
#include "bootstrap.h"
static const luaL_Reg loadedlibs[] = {
{"_G", luaopen_base},
{LUA_LOADLIBNAME, luaopen_package},
{LUA_COLIBNAME, luaopen_coroutine},
{LUA_TABLIBNAME, luaopen_table},
{LUA_IOLIBNAME, luaopen_io},
{LUA_OSLIBNAME, luaopen_os},
{LUA_STRLIBNAME, luaopen_string},
{LUA_MATHLIBNAME, luaopen_math},
{LUA_UTF8LIBNAME, luaopen_utf8},
{LUA_DBLIBNAME, luaopen_debug},
#if defined(LUA_COMPAT_BITLIB)
{LUA_BITLIBNAME, luaopen_bit32},
#endif
{"posix", luaopen_posix},
{NULL, NULL}
};
#ifdef BOOTSTRAPPING
static void __attribute__((constructor)) flua_init_env(void) {
if (getenv("LUA_PATH") == NULL)
setenv("LUA_PATH", BOOTSTRAP_FLUA_PATH, 1);
}
static void flua_setup_mods (lua_State *L) {
const luaL_Reg **flib;
SET_FOREACH(flib, FLUA_MODULE_SETNAME) {
luaL_requiref(L, (*flib)->name, (*flib)->func, 1);
lua_pop(L, 1);
}
};
#endif
LUALIB_API void luaL_openlibs (lua_State *L) {
const luaL_Reg *lib;
for (lib = loadedlibs; lib->func; lib++) {
luaL_requiref(L, lib->name, lib->func, 1);
lua_pop(L, 1);
}
#ifdef BOOTSTRAPPING
flua_setup_mods(L);
#endif
}