From 1e6ac084cf3f3b44295a55f0102dcbc4907c6fbb Mon Sep 17 00:00:00 2001 From: moteus Date: Thu, 26 Dec 2013 19:09:21 +0400 Subject: Fix. Register LuaJIT built-in libraries. --- .travis.yml | 1 + src/llthread.c | 18 +++++++++++++++++- test/test_register_ffi.lua | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/test_register_ffi.lua diff --git a/.travis.yml b/.travis.yml index 7162735..96cab16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,6 +50,7 @@ script: - lua$LUA_SFX test_register_llthreads.lua - lua$LUA_SFX test_join_timeout.lua - lua$LUA_SFX test_join_detach.lua + - lua$LUA_SFX test_register_ffi.lua notifications: email: diff --git a/src/llthread.c b/src/llthread.c index b61bf11..5bcd821 100644 --- a/src/llthread.c +++ b/src/llthread.c @@ -357,9 +357,25 @@ static void open_thread_libs(lua_State *L){ L_REGLIB(L, os, 1); L_REGLIB(L, math, 1); L_REGLIB(L, table, 1); - L_REGLIB(L, debug, 1); L_REGLIB(L, string, 1); +#ifdef LUA_DBLIBNAME + L_REGLIB(L, debug, 1); +#endif + +#ifdef LUA_BITLIBNAME + L_REGLIB(L, bit, 1); +#endif + +#ifdef LUA_JITLIBNAME + L_REGLIB(L, jit, 1); +#endif + +#ifdef LUA_FFILIBNAME + L_REGLIB(L, ffi, 1); +#endif + + lua_settop(L, top); #undef L_REGLIB } diff --git a/test/test_register_ffi.lua b/test/test_register_ffi.lua new file mode 100644 index 0000000..e98167f --- /dev/null +++ b/test/test_register_ffi.lua @@ -0,0 +1,14 @@ +if jit then + local llthreads = require "llthreads" + local thread = llthreads.new([[ + if not package.preload.ffi then + print("ffi does not register in thread") + os.exit(-1) + end + local ok, err = pcall(require, "ffi") + if not ok then + print("can not load ffi: ", err) + os.exit(-2) + end + ]]):start():join() +end -- cgit v1.2.3-55-g6feb