aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lj_lib.c10
-rw-r--r--src/lj_lib.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/src/lj_lib.c b/src/lj_lib.c
index bdbaba1d..df66ed51 100644
--- a/src/lj_lib.c
+++ b/src/lj_lib.c
@@ -148,6 +148,16 @@ void lj_lib_register(lua_State *L, const char *libname,
148 } 148 }
149} 149}
150 150
151void lj_lib_prereg(lua_State *L, const char *name, lua_CFunction f, GCtab *env)
152{
153 luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 4);
154 lua_pushcfunction(L, f);
155 /* NOBARRIER: The function is new (marked white). */
156 setgcref(funcV(L->top-1)->c.env, obj2gco(env));
157 lua_setfield(L, -2, name);
158 L->top--;
159}
160
151/* -- Type checks --------------------------------------------------------- */ 161/* -- Type checks --------------------------------------------------------- */
152 162
153TValue *lj_lib_checkany(lua_State *L, int narg) 163TValue *lj_lib_checkany(lua_State *L, int narg)
diff --git a/src/lj_lib.h b/src/lj_lib.h
index 463bfb60..f9377bad 100644
--- a/src/lj_lib.h
+++ b/src/lj_lib.h
@@ -89,6 +89,8 @@ static LJ_AINLINE GCfunc *lj_lib_pushcc(lua_State *L, lua_CFunction f,
89 89
90LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, 90LJ_FUNC void lj_lib_register(lua_State *L, const char *libname,
91 const uint8_t *init, const lua_CFunction *cf); 91 const uint8_t *init, const lua_CFunction *cf);
92LJ_FUNC void lj_lib_prereg(lua_State *L, const char *name, lua_CFunction f,
93 GCtab *env);
92 94
93/* Library init data tags. */ 95/* Library init data tags. */
94#define LIBINIT_LENMASK 0x3f 96#define LIBINIT_LENMASK 0x3f