develooper Front page | perl.perl5.porters | Postings from March 2014

Re: New API to store symbol names along pointers to symbols shared libs

Thread Previous
From:
Reini Urban
Date:
March 26, 2014 20:00
Subject:
Re: New API to store symbol names along pointers to symbols shared libs
Message ID:
CAHiT=DGwusUTz6hm6ijV-Bv7+jJ5X5ZAptktS=1_tFr_8JKFow@mail.gmail.com
On Wed, Mar 26, 2014 at 2:30 PM, Zefram <zefram@fysh.org> wrote:
> Reini Urban wrote:
>> handle = dlopen(sofile("Encode"), RTLD_NOW|RTLD_NOLOAD);
>> ptr = dlsym(handle, name);
>> xpvmg_list[0].xiv_iv = PTR2IV(ptr);
>
> Way too specific.  Pointing to C data structures from IV slots is a
> common pattern, sure, but even in the relatively unusual case where the
> data structures are statically allocated there's no reason to expect
> that the pointer would correspond to an external-linkage symbol in the
> module's .so.  That they do in the case of Encode is an accident of
> implementation, not an architectural necessity.

Fragile yes, but sufficient so far.

I could store a blessed object as ref to a blessed object, and the inner
object can be easier identified then. But which stash name or magic
to choose then?

-- 
Reini Urban
http://cpanel.net/   http://www.perl-compiler.org/

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About