On Mon, Nov 17, 2008 at 3:51 PM, Vesa Karvonen <span dir="ltr"><<a href="mailto:vesa.a.j.k@gmail.com">vesa.a.j.k@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">>> Looks like the origin was to get mlnlffi working on MinGW:<br>
>> <a href="http://mlton.org/pipermail/mlton/2006-November/029349.html" target="_blank">http://mlton.org/pipermail/mlton/2006-November/029349.html</a><br>
<br>
</div>Yes, that is why I initially wrote them. It is a minimal<br>
implementation and doesn't necessarily work as an absolute complete<br>
replacement for dl* functions.</blockquote><div><br>Ok, so we can remove the MLton ones? I think they are broken atm anyway since they get prefix with MLton_ by the mingw.h. <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> Using dlfcn-win32 does seem the best approach. I'd like to hear<br><div class="Ih2E3d">
> something from Vesa before removing them.<br>
<br>
</div>Frankly, after a very brief look at the code of dlfcn-win32<br>
(<a href="http://code.google.com/p/dlfcn-win32/source/browse/trunk/dlfcn.c" target="_blank">http://code.google.com/p/dlfcn-win32/source/browse/trunk/dlfcn.c</a>),<br>
I'm not very impressed with it. I may be mistaken and it might be<br>
mostly harmless, but it seems to leak library handles when RTLD_GLOBAL<br>
is specified. Specifically, the code seems to first execute<br>
LoadLibraryEx, which increments the reference count of the library,<br>
then if RTLD_GLOBAL is specified, the library handle is added to the<br>
doubly linked list (#1) --- except when the library was already<br>
loaded, in which case no matching call to FreeLibrary seems to be<br>
made, which means that the handle was leaked.<br>
<br>
But, it is probably better to use it anyway (at least after all the<br>
obvious bugs have been fixed), because then we don't have to maintain<br>
a similar library.</blockquote><div><br></div></div>Since you are obviously the resident expert, maybe help them it? I was thinking we could just include their (fixed) library in the MLton mingw installer. That way things will just work for users by adding -ldl, but otherwise we don't throw these symbols into your program. This seems the ideal solution to me since as DLL the wiki _import libdl examples will work unchanged with their default external scope.<br>