lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Tue, Sep 27, 2011 at 11:43 PM, Tim Caswell <> wrote:
> As some of you may have heard, I'm having great fun porting nodeJS to
> luajit. <>
> 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:

The symbols may already be available through this without having to
explicitly load, you would just need to use ffi.cdef() to declare

(I'm not certain because I haven't tried this for myself, but it
should work from my understanding.)