Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How best to write a cross-platform .xs module using x64 assembler?

by salva (Canon)
on Mar 28, 2017 at 09:37 UTC ( [id://1186224]=note: print w/replies, xml ) Need Help??


in reply to How best to write a cross-platform .xs module using x64 assembler?

First write a XS/C version of your module trying to keep clearly separated what is interface to Perl (the XS side) from the code implementing the algorithm (the C side).

Then add the assembler code inlined into the C function implementing the algorithm guarded by compiler macros so that the asm version is used on the platforms supporting it (i.e. x86_64) and the pure C on those that doesn't.

Another approach is to include the asm version of the function in its own .S file, but then you will have to add the rules for its compilation into the Makefile. Nowadays, most perls are compiled with gcc which can also be used to compile assembler code, so it should be a relatively easy task!

In order to detect when to use the C version or the asm version you can access the perl build configuration using Config, or in case that's not enough, you can go for Config::AutoConf.

  • Comment on Re: How best to write a cross-platform .xs module using x64 assembler?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-26 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found