Here's an XS file for a module and package My::Mod.
It contains a function named foo() that recursively calls itself until the supplied integer argument has been incremented to 20 (whereupon it returns the value '20').
If the supplied integer argument is >= 20, it returns that value immediately ... and if the supplied integer argument is a *lot* less than 20, then it might take a while to complete.
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
int foo(int x) {
if(x >= 20) return x;
x++;
x = foo(x);
}
MODULE = My::Mod PACKAGE = My::Mod
PROTOTYPES: DISABLE
int
foo (x)
int x
Cheers,
Rob