2 ** Library initialization.
3 ** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
5 ** Major parts taken verbatim from the Lua interpreter.
6 ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
18 static const luaL_Reg lj_lib_load
[] = {
20 { LUA_LOADLIBNAME
, luaopen_package
},
21 { LUA_TABLIBNAME
, luaopen_table
},
22 { LUA_IOLIBNAME
, luaopen_io
},
23 { LUA_OSLIBNAME
, luaopen_os
},
24 { LUA_STRLIBNAME
, luaopen_string
},
25 { LUA_MATHLIBNAME
, luaopen_math
},
26 { LUA_DBLIBNAME
, luaopen_debug
},
27 { LUA_BITLIBNAME
, luaopen_bit
},
28 { LUA_JITLIBNAME
, luaopen_jit
},
32 static const luaL_Reg lj_lib_preload
[] = {
34 { LUA_FFILIBNAME
, luaopen_ffi
},
39 LUALIB_API
void luaL_openlibs(lua_State
*L
)
42 for (lib
= lj_lib_load
; lib
->func
; lib
++) {
43 lua_pushcfunction(L
, lib
->func
);
44 lua_pushstring(L
, lib
->name
);
47 luaL_findtable(L
, LUA_REGISTRYINDEX
, "_PRELOAD",
48 sizeof(lj_lib_preload
)/sizeof(lj_lib_preload
[0])-1);
49 for (lib
= lj_lib_preload
; lib
->func
; lib
++) {
50 lua_pushcfunction(L
, lib
->func
);
51 lua_setfield(L
, -2, lib
->name
);