[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT calling embedded code.
- From: Duncan Cross <duncan.cross@...>
- Date: Wed, 28 Sep 2011 00:57:48 +0100
On Tue, Sep 27, 2011 at 11:43 PM, Tim Caswell <tim@creationix.com> wrote:
> As some of you may have heard, I'm having great fun porting nodeJS to
> luajit. <https://github.com/creationix/luvit>
> While working on the C bindings for libuv, I was told by a coworker who has
> used luajit that I should be using the ffi module instead of writing manual
> C bindings.
> His reasoning (and repeated by Mike in the FFI docs) is that the jit can
> better optimize ffi calls than raw C bound calls since it know what they
> will be doing.
> My problem is I'm binding to a library that's part of my binary. It's not
> ever compiled as a shared object that I can dlopen. Is it possible to use
> the ffi module to open symbols on my own running binary?
> If this is possible, and it would indeed be faster, how would I go about
> trying this?
> -Tim Caswell
Have a look at the ffi.C namespace object:
http://luajit.org/ext_ffi_api.html#ffi_C
The symbols may already be available through this without having to
explicitly load, you would just need to use ffi.cdef() to declare
them.
(I'm not certain because I haven't tried this for myself, but it
should work from my understanding.)
-Duncan