emacs-devel
[Top][All Lists]
Advanced

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

Re: FFI in Emacs


From: Eli Zaretskii
Subject: Re: FFI in Emacs
Date: Tue, 12 Mar 2013 23:50:46 +0200

> Date: Tue, 12 Mar 2013 20:16:42 +0100
> From: Aurélien Aptel <address@hidden>
> Cc: address@hidden
> 
> a) load the shared library dynamically
> b) get the address of any symbol in it (be it a global var or a function).
> 
> Then, to call a function:
> c) load the argument according to user-provided type and ABI
> d) make the call
> e) retrieve eventual return value (also depends on ABI)
> 
> Steps a and b can be done portably using libltdl [1]; c,d and e with
> libffi [2] or libffcall [3].

Do we really need these libraries?  If the Posix hosts can do with
dlopen, dlsym, dlclose, and dlerror, then it's very easy to emulate
that on platforms that don't have these in the system libraries.  What
else is needed, and why?

> a) a function can allocate memory that has to be freed

At least on Windows, this cannot be done safely, so please don't
design the interface based on the assumption this is doable.  If a
shared object allocates memory, it should be responsible for freeing
it, or provide an API for telling it to free it.

Likewise with file descriptors -- they cannot be safely shared across
the interface, because the shared library could have used a different
runtime for opening files.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]