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.