I have a complex encoding function in Pure Perl which I am converting to XS in the hope of gaining a performance boost.
The function I am converting to XS needs to recursively call itself. I can see how to use call_sv [thanks to "man perlcall"] to call Pure Perl functions.
But how the heck do I call myself (or any other XS function) from within XS?
(P.S. Efficiency is very desirable...)
Can somebody throw me a hint? Or an example? P-p-p-please!
UPDATE: First answer was absolutely correct. Calling out to recursive pure C functions works just fine.
Don't. XS is a mechanism to provide a Perl interface to a C function. Don't call the XS function from the C function (for which you'd use call_sv
or the like); call the C function from the XS function.
Write your recursive C function and keep it outside of the XS code (before the MODULE =
line or in a separate .c
). Call it from a thin XS wrapper.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With