FFI - can I access external constants?

Andreas Raab andreas.raab at gmx.de
Wed Feb 14 02:18:29 UTC 2007


John M McIntosh wrote:
> Ah, of course obviously if there is some way to expose the value via a 
> library call, you could do that in FFI.
> Like use dlsym() to get the address of the constant, then memcpy to a 
> squeak external data object....

Good point! Of course, you can just use FFI to access dlopen(), dlsym() 
and friends and then construct the appropriate handle from it. It's a 
little bit awkward and I don't know if that works correctly on all 
platforms (e.g. whether the system will use the already mapped shared 
library or actually map a new one) but if you're really desperate this 
is definitely worth trying.

Cheers,
   - Andreas

> 
> 
> On Feb 13, 2007, at 1:34 PM, Andreas Raab wrote:
> 
>> Jim McLoughlin wrote:
>>> I want to access some constant structures defined in my external lib.
>>> If there was a function that returned them, it would be no problem,
>>> but I don't see any obvious way to directly access them.
>>
>> Unfortunately, there isn't. The FFI doesn't expose the direct 
>> equivalent of dlsym() but only uses it implicitly when invoking an FFI 
>> call. I guess this should be considered a bug...
>>
>> Cheers,
>>   - Andreas
>>
> 
> -- 
> ===========================================================================
> John M. McIntosh <johnmci at smalltalkconsulting.com>
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
> 
> 
> 
> 




More information about the Squeak-dev mailing list