[plt-scheme] ffi: dlopen in unix

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Thu Oct 12 19:26:45 EDT 2006

>> How about just a 3rd parameter to ffi-lib, 'global or 'local which would
>> correspond directly to RTLD_GLOBAL or RTLD_LOCAL?
> That would be the obvious solution, but there is already an optional
> second argument to the core function (telling it to return #f instead
> of an error), and there is also RTLD_NOW that can be controlled by an
> option.  Finally, this:
Maybe a separate function then? Have ffi-lib-global and ffi-lib-local
where ffi-lib defaults to ffi-lib-global.
> On Oct 11, Hans Oesterholt-Dijkema wrote:
>> Would that not break compatibility with e.g. windows?
> is another concern.
> On Oct 11, Jon Rafkind wrote:
>> From the code foreign.c uses and random googling it seems like
>> Windows doesn't differentiate between global and local symbols so I
>> guess the flag could just be ignored on Windows.
> Still, it would be good to know if there is some equivalent for this
> on Windows.
I dont know where the definitive answer would be but it seems like the
python people ignore any flags as well on Windows.


*class PyDLL*( 	name, mode=DEFAULT_MODE, handle=None)

    Instances of this class behave like CDLL instances, except that the
    Python GIL is /not/ released during the function call, and after the
    function execution the Python error flag is checked. If the error
    flag is set, a Python exception is raised.

    Thus, this is only useful to call Python C api functions directly.

All these classes can be instantiated by calling them with at least one
argument, the pathname of the shared library. If you have an existing
handle to an already loaded shard library, it can be passed as the
|handle| named parameter, otherwise the underlying platforms |dlopen| or
LoadLibrary function is used to load the library into the process, and
to get a handle to it.

The mode parameter can be used to specify how the library is loaded. For
details, consult the |dlopen(3)| manpage, on Windows, mode is ignored.

Posted on the users mailing list.