require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&NNPFS_QUEUE_H)) {
    eval 'sub NNPFS_QUEUE_H () {1;}' unless defined(&NNPFS_QUEUE_H);
    eval 'sub NNPQUEUE_HEAD {
        my($name, $type) = @_;
	    eval q(\'struct name\' { \'struct type\' * &nnpq_first; \'struct type\' ** &nnpq_last; });
    }' unless defined(&NNPQUEUE_HEAD);
    eval 'sub NNPQUEUE_ENTRY {
        my($type) = @_;
	    eval q(\'struct struct\' { \'struct type\' * &nnpq_next, ** &nnpq_prev; });
    }' unless defined(&NNPQUEUE_ENTRY);
    eval 'sub NNPQUEUE_EMPTY {
        my($head) = @_;
	    eval q((($head)-> &nnpq_first ==  &NULL));
    }' unless defined(&NNPQUEUE_EMPTY);
    eval 'sub NNPQUEUE_INIT {
        my($head) = @_;
	    eval q( &do { ($head)-> &nnpq_first =  &NULL; ($head)-> &nnpq_last = ($head)-> &nnpq_first; }  &while (0));
    }' unless defined(&NNPQUEUE_INIT);
    eval 'sub NNPQUEUE_INSERT_HEAD {
        my($head, $elm, $field) = @_;
	    eval q( &do {  &if ((($elm)-> ($field->{nnpq_next}) = ($head)-> &nnpq_first) !=  &NULL) ($head)-> ($nnpq_first->{field}->{nnpq_prev}) = ($elm)-> ($field->{nnpq_next});  &else ($head)-> &nnpq_last = ($elm)-> ($field->{nnpq_next}); ($head)-> &nnpq_first = ($elm); ($elm)-> ($field->{nnpq_prev}) = ($head)-> &nnpq_first; }  &while (0));
    }' unless defined(&NNPQUEUE_INSERT_HEAD);
    eval 'sub NNPQUEUE_REMOVE {
        my($elm,$head,$field) = @_;
	    eval q( &do {  &if ((($elm)-> ($field->{nnpq_next})) !=  &NULL) ($elm)-> ($field->{nnpq_next}->{field}->{nnpq_prev}) = ($elm)-> ($field->{nnpq_prev});  &else ($head)-> &nnpq_last = ($elm)-> ($field->{nnpq_prev}); *($elm)-> ($field->{nnpq_prev}) = ($elm)-> ($field->{nnpq_next}); }  &while(0));
    }' unless defined(&NNPQUEUE_REMOVE);
    eval 'sub NNPQUEUE_FOREACH {
        my($var,$head,$field) = @_;
	    eval q( &for (($var) = (($head)-> &nnpq_first); ($var); ($var) = (($var)-> ($field->{nnpq_next}))));
    }' unless defined(&NNPQUEUE_FOREACH);
}
1;
