lua-users home
lua-l archive

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



On Apr 3, 2007, at 4:00 PM, Sam Roberts wrote:

Windows can do special tricks as well, but AFAIK the Unix-type  
systems don't offer anything special, and you have to use Posix  
threads functionality for thread-local storage. For code designed  
to be portable within the Posix family the use of the 'PRIVATE'  
flag is an impediment to portability. For that reason alone it  
needs to be removed.

Why is PRIVATE an impediment to portability? Isn't it necessary for safe
requiring of a binary module into completely seperate lua "universes"?


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.

Is it not uniformly implemented on dl systems?

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.


I'd swear that you had explained to me why it was necessary! Maybe I'm
confused. :-)

This is confusing :-)


Cheers,
Sam




--
Gé Weijers