require '_h2ph_pre.ph';

unless(defined(&_NETISO_TP_SEQ_H_)) {
    eval 'sub _NETISO_TP_SEQ_H_ () {1;}' unless defined(&_NETISO_TP_SEQ_H_);
    eval 'sub SEQ {
        local($tpcb,$x) = @_;
	    eval q((($x) & ($tpcb)-> &tp_seqmask));
    }' unless defined(&SEQ);
    eval 'sub SEQ_GT {
        local($tpcb, $seq, $operand ) = @_;
	    eval q(( ((-) > 0)? ((-) < -> &tp_seqhalf): !(-(-) < ($tpcb)-> &tp_seqhalf)));
    }' unless defined(&SEQ_GT);
    eval 'sub SEQ_GEQ {
        local($tpcb, $seq, $operand ) = @_;
	    eval q(( ((-) >= 0)? ((-) < -> &tp_seqhalf): !((-(-)) < ($tpcb)-> &tp_seqhalf)));
    }' unless defined(&SEQ_GEQ);
    eval 'sub SEQ_LEQ {
        local($tpcb, $seq, $operand ) = @_;
	    eval q(( ((-) <= 0)? ((-(-)) < -> &tp_seqhalf): !((-) < ($tpcb)-> &tp_seqhalf)));
    }' unless defined(&SEQ_LEQ);
    eval 'sub SEQ_LT {
        local($tpcb, $seq, $operand ) = @_;
	    eval q(( ((-) < 0)? ((-(-)) < -> &tp_seqhalf): !((-) < ($tpcb)-> &tp_seqhalf)));
    }' unless defined(&SEQ_LT);
    eval 'sub SEQ_MIN {
        local($tpcb, $a, $b) = @_;
	    eval q((  &SEQ_GT($tpcb, $a, $b) ? $b : $a));
    }' unless defined(&SEQ_MIN);
    eval 'sub SEQ_MAX {
        local($tpcb, $a, $b) = @_;
	    eval q((  &SEQ_GT($tpcb, $a, $b) ? $a : $b));
    }' unless defined(&SEQ_MAX);
    eval 'sub SEQ_INC {
        local($tpcb, $Seq) = @_;
	    eval q(((++$Seq), (($Seq) &= ($tpcb)-> &tp_seqmask)));
    }' unless defined(&SEQ_INC);
    eval 'sub SEQ_DEC {
        local($tpcb, $Seq) = @_;
	    eval q(( = ((+(($tpcb)-> &tp_seqbit - 1))($tpcb)-> &tp_seqmask)));
    }' unless defined(&SEQ_DEC);
    eval 'sub SEQ_SUB {
        local($tpcb, $Seq, $amt) = @_;
	    eval q((( + (($tpcb)-> &tp_seqbit - $amt)) & ($tpcb)-> &tp_seqmask));
    }' unless defined(&SEQ_SUB);
    eval 'sub SEQ_ADD {
        local($tpcb, $Seq, $amt) = @_;
	    eval q((( + $amt) & ($tpcb)-> &tp_seqmask));
    }' unless defined(&SEQ_ADD);
    eval 'sub IN_RWINDOW {
        local($tpcb, $seq, $lwe, $uwe) = @_;
	    eval q((  &SEQ_GEQ($tpcb, $seq, $lwe)  &&  &SEQ_LT($tpcb, $seq, $uwe) ));
    }' unless defined(&IN_RWINDOW);
    eval 'sub IN_SWINDOW {
        local($tpcb, $seq, $lwe, $uwe) = @_;
	    eval q((  &SEQ_GT($tpcb, $seq, $lwe)  &&  &SEQ_LEQ($tpcb, $seq, $uwe) ));
    }' unless defined(&IN_SWINDOW);
}
1;
