|
On Apr 3, 2007, at 4:00 PM, Sam Roberts wrote:
Mac OS X seems to be the only system that allows you to load multiple instances of modules dynamically. The rest of them, *BSD, Linux, Solaris, HP-UX, Windows and probably others use shared code and data within a process. The semantics of the Lua dynamic loader routines on Mac OS X are therefor Mac OS X specific, and hard to implement on other platforms. That's about as non-portable as it gets :-) If your module is written in a reentrant way (i.e. global variables are not written to, or writing is protected by locks) you can get the modules to run on any platform. Relying on the Mac OS X semantics makes the whole thing hard to port. If you use a non-reentrant library with your Lua extension you have to link it statically to the Lua extension, otherwise it gets shared anyway.
If you call 'dlopen' multiple times a module is only loaded once, and a reference count is maintained. The end result is that the 'data' and 'bss' segments in the dynamic library are not replicated.
This is confusing :-)
-- Gé Weijers |