Search the web
Sign In
New User? Sign Up
perl5-porters
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Exporting C symbols with XS   Message List  
Reply | Forward Message #89843 of 89846 |
Re: Exporting C symbols with XS

"David M. Lloyd" wrote:

> Is there a standard, platform-independant way I can export some C function
> names from my XS module that allows other modules to use them?

I've done this on Solaris by expressing an explicit linker dependency
between the calling XS module and the called XS module, that way when the
calling module is loaded via dlopen() the called module automatically gets
loaded and linked by the dynamic linker. The subsequent dlopen() of the
called module by DynaLoader just returns a reference to the already-loaded
module.

The appropriate magic is to put the following in the parameter list of the
callers WriteMakefile:

dynamic_lib => { OTHERLDFLAGS =>
'-h Caller.so ' .
'-R\$$ORIGIN/../Callee $(INST_ARCHAUTODIR)/../Callee/Callee.so ' .
},

And this in the callees:

dynamic_lib => { OTHERLDFLAGS => '-h Callee.so' },


the '-h' defines the soname of the shared object, so that the linker can tie
together the caller and callee. The -R\$$ORIGIN/../Callee tells the linker
where to look for the callee relative to the caller, so you don't have to
diddle around with LD_LIBRARY_PATH.

Here is what you end up with:

$ dump -Lv Caller.so

**** DYNAMIC SECTION INFORMATION ****
.dynamic:
[INDEX] Tag Value
[1] NEEDED Callee.so
:
[6] SONAME Caller.so
[7] RUNPATH $ORIGIN/../Callee
[8] RPATH $ORIGIN/../Callee
:

Unfortunately this fails the 'portable' bit of the requirement, as it is
Solaris-specific. It is a neat trick however, and it avoids all that
tedious mucking about with having to implement your own vtables :-)

--
Alan Burlison
--
$ head -1 /dev/bollocks
conceptualize horizontal design patterns



Wed Jul 11, 2001 12:28 pm

Alan.Burlison@...
Send Email Send Email

Forward
Message #89843 of 89846 |
Expand Messages Author Sort by Date

Is there a standard, platform-independant way I can export some C function names from my XS module that allows other modules to use them? My Callback module...
David M. Lloyd
dmlloyd@...
Send Email
Jul 10, 2001
7:55 pm

Both Tk and PDL create a vtable in the XS layer and store a pointer to it in a package variable. In the BOOT section of a second module you simply retrieve the...
Tim Jenness
t.jenness@...
Send Email
Jul 11, 2001
8:28 am

... I've done this on Solaris by expressing an explicit linker dependency between the calling XS module and the called XS module, that way when the calling...
Alan Burlison
Alan.Burlison@...
Send Email
Jul 11, 2001
12:29 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help