cvs commit: hugs98/src ffi.c static.c connect.h

ross 2003/01/03 08:12:50 PST Modified files: src ffi.c static.c connect.h Log: Enable FFI modules to be used as statically linked plugins. If the generated C code for a module is compiled with -DSTATIC_LINKAGE, the initModule() function is renamed to something based on the module name, e.g. initFMAlloc() for Foreign.Marshal.Alloc (abbreviated for limited linkers). Revision Changes Path 1.22 +22 -3 hugs98/src/ffi.c 1.131 +4 -3 hugs98/src/static.c 1.59 +3 -3 hugs98/src/connect.h

Enable FFI modules to be used as statically linked plugins.
If the generated C code for a module is compiled with -DSTATIC_LINKAGE, the initModule() function is renamed to something based on the module name, e.g. initFMAlloc() for Foreign.Marshal.Alloc (abbreviated for limited linkers).
IIRC, when I wrote the static linkage code, using this required you to either modify plugins.c or compile plugins.c with -DPLUGINS='{"Foreign.Marshal.Alloc", initFMAlloc}' These work but could obviously get a bit tedious/ hard to maintain. If you haven't already done so, it would be very, very cool to make use of the ELF / DLL initializer feature. My thought is that you could replace the 'pluginList' array in plugins.c with a linked list (changing the 'havePlugin' code as required) and that initializers would just add themselves to the linked list. (Obviously, you'd want to retain a non-ELF/DLL option as well.) It's tempting to make the initFMAlloc function an ELF initializer directly but that won't work because Hugs isn't initialized and because the code that implements foreign export is supposed to be able to perform a lookup when the module is initialized. (I say 'supposed' because the frontend parts of foreign export still don't exist.) -- Alastair

On Fri, Jan 03, 2003 at 07:25:51PM +0000, Alastair Reid wrote:
IIRC, when I wrote the static linkage code, using this required you to either modify plugins.c or compile plugins.c with
-DPLUGINS='{"Foreign.Marshal.Alloc", initFMAlloc}'
Yes, you left a comment to this effect.
These work but could obviously get a bit tedious/ hard to maintain.
If you haven't already done so, it would be very, very cool to make use of the ELF / DLL initializer feature.
I was doing the tedious thing, and thinking maybe it could be done in the Makefile some day. But isn't the principal advantage of plugins that they let you use FFI-using library modules even on systems without dynamic loading? What would this buy you over the current setup?
participants (3)
-
Alastair Reid
-
Ross Paterson
-
ross@glass.cse.ogi.edu