Your documentation says:
"Your program can check whether Readonly.pm is using XS or not by
examining the $Readonly::XSokay variable. [...] Please do not change
this variable."
Why don't you write-protect this variable in the first place?
Of course anyone can unprotect it afterwards if they want to, but this
will at least protect against the unwary, or against bugs in user code.