Abstract out on-demand loading of FFI library.

This commit is contained in:
Mike Pall
2021-06-01 01:01:15 +02:00
parent 61990cef05
commit 50d6883e60
4 changed files with 13 additions and 15 deletions

View File

@@ -389,6 +389,16 @@ static LJ_AINLINE CTState *ctype_cts(lua_State *L)
return cts;
}
/* Load FFI library on-demand. */
#define ctype_loadffi(L) \
do { \
if (!ctype_ctsG(G(L))) { \
ptrdiff_t oldtop = (char *)L->top - mref(L->stack, char); \
luaopen_ffi(L); \
L->top = (TValue *)(mref(L->stack, char) + oldtop); \
} \
} while (0)
/* Save and restore state of C type table. */
#define LJ_CTYPE_SAVE(cts) CTState savects_ = *(cts)
#define LJ_CTYPE_RESTORE(cts) \