require '_h2ph_pre.ph';

unless(defined(&_LINUX_CIRC_BUF_H)) {
    eval 'sub _LINUX_CIRC_BUF_H () {1;}' unless defined(&_LINUX_CIRC_BUF_H);
    eval 'sub CIRC_CNT {
        local($head,$tail,$size) = @_;
	    eval q(((($head) - ($tail)) & (($size)-1)));
    }' unless defined(&CIRC_CNT);
    eval 'sub CIRC_SPACE {
        local($head,$tail,$size) = @_;
	    eval q( &CIRC_CNT(($tail),(($head)+1),($size)));
    }' unless defined(&CIRC_SPACE);
    eval 'sub CIRC_CNT_TO_END {
        local($head,$tail,$size) = @_;
	    eval q(({\'int\'  &end = ($size) - ($tail); \'int\'  &n = (($head) +  &end) & (($size)-1);  &n <  &end ?  &n :  &end;}));
    }' unless defined(&CIRC_CNT_TO_END);
    eval 'sub CIRC_SPACE_TO_END {
        local($head,$tail,$size) = @_;
	    eval q(({\'int\'  &end = ($size) - 1- ($head); \'int\'  &n = ( &end + ($tail)) & (($size)-1);  &n <=  &end ?  &n :  &end+1;}));
    }' unless defined(&CIRC_SPACE_TO_END);
}
1;
