Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Dynaloader/XS: sharing C symbols across shared objects

by salva (Abbot)
on Jun 10, 2008 at 07:53 UTC ( #691174=note: print w/replies, xml ) Need Help??

in reply to Dynaloader/XS: sharing C symbols across shared objects

There is another way to do it:

On the "server" module expose a perl function (or a global variable) that returns a pointer to a table containing pointers to all the functions that you want to share. Then on the "client" module, at boot, call the function returning the table pointer and save it into a static variable for later usage. For instance, Time::HiRes uses that approach.

It is more laborious but also guaranteed to work in any operative system while the dl_load_flags feature seems to be available only in some OSs.

  • Comment on Re: Dynaloader/XS: sharing C symbols across shared objects

Replies are listed 'Best First'.
Re^2: Dynaloader/XS: sharing C symbols across shared objects
by creamygoodness (Curate) on Jun 10, 2008 at 19:26 UTC
    Thanks for this very useful tip, salva. It's a brute force technique, and I can see why it's reliable -- all you're doing is passing around function pointers wrapped in Perl SVs.

    There are only four or five symbols in the Snowball C API, so I can add a full public C API to Lingua::Stem::Snowball without too much effort, directly emulating the C API for Time::HiRes.

    Marvin Humphrey
    Rectangular Research ―

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://691174]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2020-08-13 08:27 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (69 votes). Check out past polls.