require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_QUEUE_H_)) {
    eval 'sub _SYS_QUEUE_H_ () {1;}' unless defined(&_SYS_QUEUE_H_);
    if(defined(&__NetBSD__)) {
	require 'sys/null.ph';
    }
    if(defined(&_KERNEL)  && defined(&DIAGNOSTIC)) {
	eval 'sub QUEUEDEBUG () {1;}' unless defined(&QUEUEDEBUG);
    }
    if(defined(&QUEUEDEBUG)) {
	if(defined(&_KERNEL)) {
	    eval 'sub QUEUEDEBUG_ABORT () {(...)  &panic( &__VA_ARGS__);}' unless defined(&QUEUEDEBUG_ABORT);
	} else {
	    require 'err.ph';
	    eval 'sub QUEUEDEBUG_ABORT () {(...)  &err(1,  &__VA_ARGS__);}' unless defined(&QUEUEDEBUG_ABORT);
	}
    }
    eval 'sub SLIST_HEAD {
        my($name, $type) = @_;
	    eval q(\'struct name\' { \'struct type\' * &slh_first; });
    }' unless defined(&SLIST_HEAD);
    eval 'sub SLIST_HEAD_INITIALIZER {
        my($head) = @_;
	    eval q({  &NULL });
    }' unless defined(&SLIST_HEAD_INITIALIZER);
    eval 'sub SLIST_ENTRY {
        my($type) = @_;
	    eval q(\'struct struct\' { \'struct type\' * &sle_next; });
    }' unless defined(&SLIST_ENTRY);
    eval 'sub SLIST_FIRST {
        my($head) = @_;
	    eval q((($head)-> &slh_first));
    }' unless defined(&SLIST_FIRST);
    eval 'sub SLIST_END {
        my($head) = @_;
	    eval q( &NULL);
    }' unless defined(&SLIST_END);
    eval 'sub SLIST_EMPTY {
        my($head) = @_;
	    eval q((($head)-> &slh_first ==  &NULL));
    }' unless defined(&SLIST_EMPTY);
    eval 'sub SLIST_NEXT {
        my($elm, $field) = @_;
	    eval q((($elm)-> ($field->{sle_next})));
    }' unless defined(&SLIST_NEXT);
    eval 'sub SLIST_FOREACH {
        my($var, $head, $field) = @_;
	    eval q( &for(($var) = ($head)-> &slh_first; ($var) !=  &SLIST_END($head); ($var) = ($var)-> ($field->{sle_next})));
    }' unless defined(&SLIST_FOREACH);
    eval 'sub SLIST_FOREACH_SAFE {
        my($var, $head, $field, $tvar) = @_;
	    eval q( &for (($var) =  &SLIST_FIRST(($head)); ($var) !=  &SLIST_END($head)  && (($tvar) =  &SLIST_NEXT(($var), $field), 1); ($var) = ($tvar)));
    }' unless defined(&SLIST_FOREACH_SAFE);
    eval 'sub SLIST_INIT {
        my($head) = @_;
	    eval q( &do { ($head)-> &slh_first =  &SLIST_END($head); }  &while ( 0));
    }' unless defined(&SLIST_INIT);
    eval 'sub SLIST_INSERT_AFTER {
        my($slistelm, $elm, $field) = @_;
	    eval q( &do { ($elm)-> ($field->{sle_next}) = ($slistelm)-> ($field->{sle_next}); ($slistelm)-> ($field->{sle_next}) = ($elm); }  &while ( 0));
    }' unless defined(&SLIST_INSERT_AFTER);
    eval 'sub SLIST_INSERT_HEAD {
        my($head, $elm, $field) = @_;
	    eval q( &do { ($elm)-> ($field->{sle_next}) = ($head)-> &slh_first; ($head)-> &slh_first = ($elm); }  &while ( 0));
    }' unless defined(&SLIST_INSERT_HEAD);
    eval 'sub SLIST_REMOVE_AFTER {
        my($slistelm, $field) = @_;
	    eval q( &do { ($slistelm)-> ($field->{sle_next}) =  &SLIST_NEXT( &SLIST_NEXT(($slistelm), $field), $field); }  &while ( 0));
    }' unless defined(&SLIST_REMOVE_AFTER);
    eval 'sub SLIST_REMOVE_HEAD {
        my($head, $field) = @_;
	    eval q( &do { ($head)-> &slh_first = ($head)-> ($slh_first->{field}->{sle_next}); }  &while ( 0));
    }' unless defined(&SLIST_REMOVE_HEAD);
    eval 'sub SLIST_REMOVE {
        my($head, $elm, $type, $field) = @_;
	    eval q( &do {  &if (($head)-> &slh_first == ($elm)) {  &SLIST_REMOVE_HEAD(($head), $field); }  &else { \'struct type\' * &curelm = ($head)-> &slh_first;  &while( ($curelm->{field}->{sle_next}) != ($elm))  &curelm =  ($curelm->{field}->{sle_next});  ($curelm->{field}->{sle_next}) =  ($curelm->{field}->{sle_next}->{field}->{sle_next}); } }  &while ( 0));
    }' unless defined(&SLIST_REMOVE);
    eval 'sub LIST_HEAD {
        my($name, $type) = @_;
	    eval q(\'struct name\' { \'struct type\' * &lh_first; });
    }' unless defined(&LIST_HEAD);
    eval 'sub LIST_HEAD_INITIALIZER {
        my($head) = @_;
	    eval q({  &NULL });
    }' unless defined(&LIST_HEAD_INITIALIZER);
    eval 'sub LIST_ENTRY {
        my($type) = @_;
	    eval q(\'struct struct\' { \'struct type\' * &le_next; \'struct type\' ** &le_prev; });
    }' unless defined(&LIST_ENTRY);
    eval 'sub LIST_FIRST {
        my($head) = @_;
	    eval q((($head)-> &lh_first));
    }' unless defined(&LIST_FIRST);
    eval 'sub LIST_END {
        my($head) = @_;
	    eval q( &NULL);
    }' unless defined(&LIST_END);
    eval 'sub LIST_EMPTY {
        my($head) = @_;
	    eval q((($head)-> &lh_first ==  &LIST_END($head)));
    }' unless defined(&LIST_EMPTY);
    eval 'sub LIST_NEXT {
        my($elm, $field) = @_;
	    eval q((($elm)-> ($field->{le_next})));
    }' unless defined(&LIST_NEXT);
    eval 'sub LIST_FOREACH {
        my($var, $head, $field) = @_;
	    eval q( &for (($var) = (($head)-> &lh_first); ($var) !=  &LIST_END($head); ($var) = (($var)-> ($field->{le_next}))));
    }' unless defined(&LIST_FOREACH);
    eval 'sub LIST_FOREACH_SAFE {
        my($var, $head, $field, $tvar) = @_;
	    eval q( &for (($var) =  &LIST_FIRST(($head)); ($var) !=  &LIST_END($head)  && (($tvar) =  &LIST_NEXT(($var), $field), 1); ($var) = ($tvar)));
    }' unless defined(&LIST_FOREACH_SAFE);
    eval 'sub LIST_MOVE {
        my($head1, $head2, $field) = @_;
	    eval q( &do {  &LIST_INIT(($head2));  &if (! &LIST_EMPTY(($head1))) { ($head2)-> &lh_first = ($head1)-> &lh_first; ($head2)-> ($lh_first->{field}->{le_prev}) = ($head2)-> &lh_first;  &LIST_INIT(($head1)); } }  &while ( 0));
    }' unless defined(&LIST_MOVE);
    if(defined(&QUEUEDEBUG)) {
	eval 'sub QUEUEDEBUG_LIST_INSERT_HEAD {
	    my($head, $elm, $field) = @_;
    	    eval q( &if (($head)-> &lh_first  && ($head)-> ($lh_first->{field}->{le_prev}) != ($head)-> &lh_first)  &QUEUEDEBUG_ABORT(\\"LIST_INSERT_HEAD %p %s:%d\\", ($head),  &__FILE__,  &__LINE__););
	}' unless defined(&QUEUEDEBUG_LIST_INSERT_HEAD);
	eval 'sub QUEUEDEBUG_LIST_OP {
	    my($elm, $field) = @_;
    	    eval q( &if (($elm)-> ($field->{le_next})  && ($elm)-> ($field->{le_next}->{field}->{le_prev}) != ($elm)-> ($field->{le_next}))  &QUEUEDEBUG_ABORT(\\"LIST_* forw %p %s:%d\\", ($elm),  &__FILE__,  &__LINE__);  &if (*($elm)-> ($field->{le_prev}) != ($elm))  &QUEUEDEBUG_ABORT(\\"LIST_* back %p %s:%d\\", ($elm),  &__FILE__,  &__LINE__););
	}' unless defined(&QUEUEDEBUG_LIST_OP);
	eval 'sub QUEUEDEBUG_LIST_POSTREMOVE {
	    my($elm, $field) = @_;
    	    eval q(($elm)-> ($field->{le_next}) = ( &void *)1; ($elm)-> ($field->{le_prev}) = ( &void *)1;);
	}' unless defined(&QUEUEDEBUG_LIST_POSTREMOVE);
    } else {
	eval 'sub QUEUEDEBUG_LIST_INSERT_HEAD {
	    my($head, $elm, $field) = @_;
    	    eval q();
	}' unless defined(&QUEUEDEBUG_LIST_INSERT_HEAD);
	eval 'sub QUEUEDEBUG_LIST_OP {
	    my($elm, $field) = @_;
    	    eval q();
	}' unless defined(&QUEUEDEBUG_LIST_OP);
	eval 'sub QUEUEDEBUG_LIST_POSTREMOVE {
	    my($elm, $field) = @_;
    	    eval q();
	}' unless defined(&QUEUEDEBUG_LIST_POSTREMOVE);
    }
    eval 'sub LIST_INIT {
        my($head) = @_;
	    eval q( &do { ($head)-> &lh_first =  &LIST_END($head); }  &while ( 0));
    }' unless defined(&LIST_INIT);
    eval 'sub LIST_INSERT_AFTER {
        my($listelm, $elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_LIST_OP(($listelm), $field)  &if ((($elm)-> ($field->{le_next}) = ($listelm)-> ($field->{le_next})) !=  &LIST_END( &head)) ($listelm)-> ($field->{le_next}->{field}->{le_prev}) = ($elm)-> ($field->{le_next}); ($listelm)-> ($field->{le_next}) = ($elm); ($elm)-> ($field->{le_prev}) = ($listelm)-> ($field->{le_next}); }  &while ( 0));
    }' unless defined(&LIST_INSERT_AFTER);
    eval 'sub LIST_INSERT_BEFORE {
        my($listelm, $elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_LIST_OP(($listelm), $field) ($elm)-> ($field->{le_prev}) = ($listelm)-> ($field->{le_prev}); ($elm)-> ($field->{le_next}) = ($listelm); *($listelm)-> ($field->{le_prev}) = ($elm); ($listelm)-> ($field->{le_prev}) = ($elm)-> ($field->{le_next}); }  &while ( 0));
    }' unless defined(&LIST_INSERT_BEFORE);
    eval 'sub LIST_INSERT_HEAD {
        my($head, $elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_LIST_INSERT_HEAD(($head), ($elm), $field)  &if ((($elm)-> ($field->{le_next}) = ($head)-> &lh_first) !=  &LIST_END($head)) ($head)-> ($lh_first->{field}->{le_prev}) = ($elm)-> ($field->{le_next}); ($head)-> &lh_first = ($elm); ($elm)-> ($field->{le_prev}) = ($head)-> &lh_first; }  &while ( 0));
    }' unless defined(&LIST_INSERT_HEAD);
    eval 'sub LIST_REMOVE {
        my($elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_LIST_OP(($elm), $field)  &if (($elm)-> ($field->{le_next}) !=  &NULL) ($elm)-> ($field->{le_next}->{field}->{le_prev}) = ($elm)-> ($field->{le_prev}); *($elm)-> ($field->{le_prev}) = ($elm)-> ($field->{le_next});  &QUEUEDEBUG_LIST_POSTREMOVE(($elm), $field) }  &while ( 0));
    }' unless defined(&LIST_REMOVE);
    eval 'sub LIST_REPLACE {
        my($elm, $elm2, $field) = @_;
	    eval q( &do {  &if ((($elm2)-> ($field->{le_next}) = ($elm)-> ($field->{le_next})) !=  &NULL) ($elm2)-> ($field->{le_next}->{field}->{le_prev}) = ($elm2)-> ($field->{le_next}); ($elm2)-> ($field->{le_prev}) = ($elm)-> ($field->{le_prev}); *($elm2)-> ($field->{le_prev}) = ($elm2);  &QUEUEDEBUG_LIST_POSTREMOVE(($elm), $field) }  &while ( 0));
    }' unless defined(&LIST_REPLACE);
    eval 'sub SIMPLEQ_HEAD {
        my($name, $type) = @_;
	    eval q(\'struct name\' { \'struct type\' * &sqh_first; \'struct type\' ** &sqh_last; });
    }' unless defined(&SIMPLEQ_HEAD);
    eval 'sub SIMPLEQ_HEAD_INITIALIZER {
        my($head) = @_;
	    eval q({  &NULL, ($head). &sqh_first });
    }' unless defined(&SIMPLEQ_HEAD_INITIALIZER);
    eval 'sub SIMPLEQ_ENTRY {
        my($type) = @_;
	    eval q(\'struct struct\' { \'struct type\' * &sqe_next; });
    }' unless defined(&SIMPLEQ_ENTRY);
    eval 'sub SIMPLEQ_FIRST {
        my($head) = @_;
	    eval q((($head)-> &sqh_first));
    }' unless defined(&SIMPLEQ_FIRST);
    eval 'sub SIMPLEQ_END {
        my($head) = @_;
	    eval q( &NULL);
    }' unless defined(&SIMPLEQ_END);
    eval 'sub SIMPLEQ_EMPTY {
        my($head) = @_;
	    eval q((($head)-> &sqh_first ==  &SIMPLEQ_END($head)));
    }' unless defined(&SIMPLEQ_EMPTY);
    eval 'sub SIMPLEQ_NEXT {
        my($elm, $field) = @_;
	    eval q((($elm)-> ($field->{sqe_next})));
    }' unless defined(&SIMPLEQ_NEXT);
    eval 'sub SIMPLEQ_FOREACH {
        my($var, $head, $field) = @_;
	    eval q( &for (($var) = (($head)-> &sqh_first); ($var) !=  &SIMPLEQ_END($head); ($var) = (($var)-> ($field->{sqe_next}))));
    }' unless defined(&SIMPLEQ_FOREACH);
    eval 'sub SIMPLEQ_FOREACH_SAFE {
        my($var, $head, $field, $next) = @_;
	    eval q( &for (($var) = (($head)-> &sqh_first); ($var) !=  &SIMPLEQ_END($head)  && (($next = (($var)-> ($field->{sqe_next}))), 1); ($var) = ($next)));
    }' unless defined(&SIMPLEQ_FOREACH_SAFE);
    eval 'sub SIMPLEQ_INIT {
        my($head) = @_;
	    eval q( &do { ($head)-> &sqh_first =  &NULL; ($head)-> &sqh_last = ($head)-> &sqh_first; }  &while ( 0));
    }' unless defined(&SIMPLEQ_INIT);
    eval 'sub SIMPLEQ_INSERT_HEAD {
        my($head, $elm, $field) = @_;
	    eval q( &do {  &if ((($elm)-> ($field->{sqe_next}) = ($head)-> &sqh_first) ==  &NULL) ($head)-> &sqh_last = ($elm)-> ($field->{sqe_next}); ($head)-> &sqh_first = ($elm); }  &while ( 0));
    }' unless defined(&SIMPLEQ_INSERT_HEAD);
    eval 'sub SIMPLEQ_INSERT_TAIL {
        my($head, $elm, $field) = @_;
	    eval q( &do { ($elm)-> ($field->{sqe_next}) =  &NULL; *($head)-> &sqh_last = ($elm); ($head)-> &sqh_last = ($elm)-> ($field->{sqe_next}); }  &while ( 0));
    }' unless defined(&SIMPLEQ_INSERT_TAIL);
    eval 'sub SIMPLEQ_INSERT_AFTER {
        my($head, $listelm, $elm, $field) = @_;
	    eval q( &do {  &if ((($elm)-> ($field->{sqe_next}) = ($listelm)-> ($field->{sqe_next})) ==  &NULL) ($head)-> &sqh_last = ($elm)-> ($field->{sqe_next}); ($listelm)-> ($field->{sqe_next}) = ($elm); }  &while ( 0));
    }' unless defined(&SIMPLEQ_INSERT_AFTER);
    eval 'sub SIMPLEQ_REMOVE_HEAD {
        my($head, $field) = @_;
	    eval q( &do {  &if ((($head)-> &sqh_first = ($head)-> ($sqh_first->{field}->{sqe_next})) ==  &NULL) ($head)-> &sqh_last = ($head)-> &sqh_first; }  &while ( 0));
    }' unless defined(&SIMPLEQ_REMOVE_HEAD);
    eval 'sub SIMPLEQ_REMOVE_AFTER {
        my($head, $elm, $field) = @_;
	    eval q( &do {  &if ((($elm)-> ($field->{sqe_next}) = ($elm)-> ($field->{sqe_next}->{field}->{sqe_next})) ==  &NULL) ($head)-> &sqh_last = ($elm)-> ($field->{sqe_next}); }  &while ( 0));
    }' unless defined(&SIMPLEQ_REMOVE_AFTER);
    eval 'sub SIMPLEQ_REMOVE {
        my($head, $elm, $type, $field) = @_;
	    eval q( &do {  &if (($head)-> &sqh_first == ($elm)) {  &SIMPLEQ_REMOVE_HEAD(($head), $field); }  &else { \'struct type\' * &curelm = ($head)-> &sqh_first;  &while ( ($curelm->{field}->{sqe_next}) != ($elm))  &curelm =  ($curelm->{field}->{sqe_next});  &if (( ($curelm->{field}->{sqe_next}) =  ($curelm->{field}->{sqe_next}->{field}->{sqe_next})) ==  &NULL) ($head)-> &sqh_last = ( &curelm)-> ($field->{sqe_next}); } }  &while ( 0));
    }' unless defined(&SIMPLEQ_REMOVE);
    eval 'sub SIMPLEQ_CONCAT {
        my($head1, $head2) = @_;
	    eval q( &do {  &if (! &SIMPLEQ_EMPTY(($head2))) { *($head1)-> &sqh_last = ($head2)-> &sqh_first; ($head1)-> &sqh_last = ($head2)-> &sqh_last;  &SIMPLEQ_INIT(($head2)); } }  &while ( 0));
    }' unless defined(&SIMPLEQ_CONCAT);
    eval 'sub SIMPLEQ_LAST {
        my($head, $type, $field) = @_;
	    eval q(( &SIMPLEQ_EMPTY(($head)) ?  &NULL : (( &void *) ((($head)-> &sqh_last) -  &offsetof(\'struct type\', $field)))));
    }' unless defined(&SIMPLEQ_LAST);
    eval 'sub _TAILQ_HEAD {
        my($name, $type, $qual) = @_;
	    eval q(\'struct name\' { $qual $type * &tqh_first; $qual $type *$qual * &tqh_last; });
    }' unless defined(&_TAILQ_HEAD);
    eval 'sub TAILQ_HEAD {
        my($name, $type) = @_;
	    eval q( &_TAILQ_HEAD($name, \'struct type\',));
    }' unless defined(&TAILQ_HEAD);
    eval 'sub TAILQ_HEAD_INITIALIZER {
        my($head) = @_;
	    eval q({  &TAILQ_END($head), ($head). &tqh_first });
    }' unless defined(&TAILQ_HEAD_INITIALIZER);
    eval 'sub _TAILQ_ENTRY {
        my($type, $qual) = @_;
	    eval q(\'struct struct\' { $qual $type * &tqe_next; $qual $type *$qual * &tqe_prev; });
    }' unless defined(&_TAILQ_ENTRY);
    eval 'sub TAILQ_ENTRY {
        my($type) = @_;
	    eval q( &_TAILQ_ENTRY(\'struct type\',));
    }' unless defined(&TAILQ_ENTRY);
    eval 'sub TAILQ_FIRST {
        my($head) = @_;
	    eval q((($head)-> &tqh_first));
    }' unless defined(&TAILQ_FIRST);
    eval 'sub TAILQ_END {
        my($head) = @_;
	    eval q(( &NULL));
    }' unless defined(&TAILQ_END);
    eval 'sub TAILQ_NEXT {
        my($elm, $field) = @_;
	    eval q((($elm)-> ($field->{tqe_next})));
    }' unless defined(&TAILQ_NEXT);
    eval 'sub TAILQ_LAST {
        my($head, $headname) = @_;
	    eval q((*((( &void *)(($head)-> &tqh_last))-> &tqh_last)));
    }' unless defined(&TAILQ_LAST);
    eval 'sub TAILQ_PREV {
        my($elm, $headname, $field) = @_;
	    eval q((*((( &void *)(($elm)-> ($field->{tqe_prev})))-> &tqh_last)));
    }' unless defined(&TAILQ_PREV);
    eval 'sub TAILQ_EMPTY {
        my($head) = @_;
	    eval q(( &TAILQ_FIRST($head) ==  &TAILQ_END($head)));
    }' unless defined(&TAILQ_EMPTY);
    eval 'sub TAILQ_FOREACH {
        my($var, $head, $field) = @_;
	    eval q( &for (($var) = (($head)-> &tqh_first); ($var) !=  &TAILQ_END($head); ($var) = (($var)-> ($field->{tqe_next}))));
    }' unless defined(&TAILQ_FOREACH);
    eval 'sub TAILQ_FOREACH_SAFE {
        my($var, $head, $field, $next) = @_;
	    eval q( &for (($var) = (($head)-> &tqh_first); ($var) !=  &TAILQ_END($head)  && (($next) =  &TAILQ_NEXT($var, $field), 1); ($var) = ($next)));
    }' unless defined(&TAILQ_FOREACH_SAFE);
    eval 'sub TAILQ_FOREACH_REVERSE {
        my($var, $head, $headname, $field) = @_;
	    eval q( &for (($var) =  &TAILQ_LAST(($head), $headname); ($var) !=  &TAILQ_END($head); ($var) =  &TAILQ_PREV(($var), $headname, $field)));
    }' unless defined(&TAILQ_FOREACH_REVERSE);
    eval 'sub TAILQ_FOREACH_REVERSE_SAFE {
        my($var, $head, $headname, $field, $prev) = @_;
	    eval q( &for (($var) =  &TAILQ_LAST(($head), $headname); ($var) !=  &TAILQ_END($head)  && (($prev) =  &TAILQ_PREV(($var), $headname, $field), 1); ($var) = ($prev)));
    }' unless defined(&TAILQ_FOREACH_REVERSE_SAFE);
    if(defined(&QUEUEDEBUG)) {
	eval 'sub QUEUEDEBUG_TAILQ_INSERT_HEAD {
	    my($head, $elm, $field) = @_;
    	    eval q( &if (($head)-> &tqh_first  && ($head)-> ($tqh_first->{field}->{tqe_prev}) != ($head)-> &tqh_first)  &QUEUEDEBUG_ABORT(\\"TAILQ_INSERT_HEAD %p %s:%d\\", ($head),  &__FILE__,  &__LINE__););
	}' unless defined(&QUEUEDEBUG_TAILQ_INSERT_HEAD);
	eval 'sub QUEUEDEBUG_TAILQ_INSERT_TAIL {
	    my($head, $elm, $field) = @_;
    	    eval q( &if (*($head)-> &tqh_last !=  &NULL)  &QUEUEDEBUG_ABORT(\\"TAILQ_INSERT_TAIL %p %s:%d\\", ($head),  &__FILE__,  &__LINE__););
	}' unless defined(&QUEUEDEBUG_TAILQ_INSERT_TAIL);
	eval 'sub QUEUEDEBUG_TAILQ_OP {
	    my($elm, $field) = @_;
    	    eval q( &if (($elm)-> ($field->{tqe_next})  && ($elm)-> ($field->{tqe_next}->{field}->{tqe_prev}) != ($elm)-> ($field->{tqe_next}))  &QUEUEDEBUG_ABORT(\\"TAILQ_* forw %p %s:%d\\", ($elm),  &__FILE__,  &__LINE__);  &if (*($elm)-> ($field->{tqe_prev}) != ($elm))  &QUEUEDEBUG_ABORT(\\"TAILQ_* back %p %s:%d\\", ($elm),  &__FILE__,  &__LINE__););
	}' unless defined(&QUEUEDEBUG_TAILQ_OP);
	eval 'sub QUEUEDEBUG_TAILQ_PREREMOVE {
	    my($head, $elm, $field) = @_;
    	    eval q( &if (($elm)-> ($field->{tqe_next}) ==  &NULL  && ($head)-> &tqh_last != ($elm)-> ($field->{tqe_next}))  &QUEUEDEBUG_ABORT(\\"TAILQ_PREREMOVE head %p elm %p %s:%d\\", ($head), ($elm),  &__FILE__,  &__LINE__););
	}' unless defined(&QUEUEDEBUG_TAILQ_PREREMOVE);
	eval 'sub QUEUEDEBUG_TAILQ_POSTREMOVE {
	    my($elm, $field) = @_;
    	    eval q(($elm)-> ($field->{tqe_next}) = ( &void *)1; ($elm)-> ($field->{tqe_prev}) = ( &void *)1;);
	}' unless defined(&QUEUEDEBUG_TAILQ_POSTREMOVE);
    } else {
	eval 'sub QUEUEDEBUG_TAILQ_INSERT_HEAD {
	    my($head, $elm, $field) = @_;
    	    eval q();
	}' unless defined(&QUEUEDEBUG_TAILQ_INSERT_HEAD);
	eval 'sub QUEUEDEBUG_TAILQ_INSERT_TAIL {
	    my($head, $elm, $field) = @_;
    	    eval q();
	}' unless defined(&QUEUEDEBUG_TAILQ_INSERT_TAIL);
	eval 'sub QUEUEDEBUG_TAILQ_OP {
	    my($elm, $field) = @_;
    	    eval q();
	}' unless defined(&QUEUEDEBUG_TAILQ_OP);
	eval 'sub QUEUEDEBUG_TAILQ_PREREMOVE {
	    my($head, $elm, $field) = @_;
    	    eval q();
	}' unless defined(&QUEUEDEBUG_TAILQ_PREREMOVE);
	eval 'sub QUEUEDEBUG_TAILQ_POSTREMOVE {
	    my($elm, $field) = @_;
    	    eval q();
	}' unless defined(&QUEUEDEBUG_TAILQ_POSTREMOVE);
    }
    eval 'sub TAILQ_INIT {
        my($head) = @_;
	    eval q( &do { ($head)-> &tqh_first =  &TAILQ_END($head); ($head)-> &tqh_last = ($head)-> &tqh_first; }  &while ( 0));
    }' unless defined(&TAILQ_INIT);
    eval 'sub TAILQ_INSERT_HEAD {
        my($head, $elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_TAILQ_INSERT_HEAD(($head), ($elm), $field)  &if ((($elm)-> ($field->{tqe_next}) = ($head)-> &tqh_first) !=  &TAILQ_END($head)) ($head)-> ($tqh_first->{field}->{tqe_prev}) = ($elm)-> ($field->{tqe_next});  &else ($head)-> &tqh_last = ($elm)-> ($field->{tqe_next}); ($head)-> &tqh_first = ($elm); ($elm)-> ($field->{tqe_prev}) = ($head)-> &tqh_first; }  &while ( 0));
    }' unless defined(&TAILQ_INSERT_HEAD);
    eval 'sub TAILQ_INSERT_TAIL {
        my($head, $elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_TAILQ_INSERT_TAIL(($head), ($elm), $field) ($elm)-> ($field->{tqe_next}) =  &TAILQ_END($head); ($elm)-> ($field->{tqe_prev}) = ($head)-> &tqh_last; *($head)-> &tqh_last = ($elm); ($head)-> &tqh_last = ($elm)-> ($field->{tqe_next}); }  &while ( 0));
    }' unless defined(&TAILQ_INSERT_TAIL);
    eval 'sub TAILQ_INSERT_AFTER {
        my($head, $listelm, $elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_TAILQ_OP(($listelm), $field)  &if ((($elm)-> ($field->{tqe_next}) = ($listelm)-> ($field->{tqe_next})) !=  &TAILQ_END($head)) ($elm)-> ($field->{tqe_next}->{field}->{tqe_prev}) = ($elm)-> ($field->{tqe_next});  &else ($head)-> &tqh_last = ($elm)-> ($field->{tqe_next}); ($listelm)-> ($field->{tqe_next}) = ($elm); ($elm)-> ($field->{tqe_prev}) = ($listelm)-> ($field->{tqe_next}); }  &while ( 0));
    }' unless defined(&TAILQ_INSERT_AFTER);
    eval 'sub TAILQ_INSERT_BEFORE {
        my($listelm, $elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_TAILQ_OP(($listelm), $field) ($elm)-> ($field->{tqe_prev}) = ($listelm)-> ($field->{tqe_prev}); ($elm)-> ($field->{tqe_next}) = ($listelm); *($listelm)-> ($field->{tqe_prev}) = ($elm); ($listelm)-> ($field->{tqe_prev}) = ($elm)-> ($field->{tqe_next}); }  &while ( 0));
    }' unless defined(&TAILQ_INSERT_BEFORE);
    eval 'sub TAILQ_REMOVE {
        my($head, $elm, $field) = @_;
	    eval q( &do {  &QUEUEDEBUG_TAILQ_PREREMOVE(($head), ($elm), $field)  &QUEUEDEBUG_TAILQ_OP(($elm), $field)  &if ((($elm)-> ($field->{tqe_next})) !=  &TAILQ_END($head)) ($elm)-> ($field->{tqe_next}->{field}->{tqe_prev}) = ($elm)-> ($field->{tqe_prev});  &else ($head)-> &tqh_last = ($elm)-> ($field->{tqe_prev}); *($elm)-> ($field->{tqe_prev}) = ($elm)-> ($field->{tqe_next});  &QUEUEDEBUG_TAILQ_POSTREMOVE(($elm), $field); }  &while ( 0));
    }' unless defined(&TAILQ_REMOVE);
    eval 'sub TAILQ_REPLACE {
        my($head, $elm, $elm2, $field) = @_;
	    eval q( &do {  &if ((($elm2)-> ($field->{tqe_next}) = ($elm)-> ($field->{tqe_next})) !=  &TAILQ_END($head)) ($elm2)-> ($field->{tqe_next}->{field}->{tqe_prev}) = ($elm2)-> ($field->{tqe_next});  &else ($head)-> &tqh_last = ($elm2)-> ($field->{tqe_next}); ($elm2)-> ($field->{tqe_prev}) = ($elm)-> ($field->{tqe_prev}); *($elm2)-> ($field->{tqe_prev}) = ($elm2);  &QUEUEDEBUG_TAILQ_POSTREMOVE(($elm), $field); }  &while ( 0));
    }' unless defined(&TAILQ_REPLACE);
    eval 'sub TAILQ_CONCAT {
        my($head1, $head2, $field) = @_;
	    eval q( &do {  &if (! &TAILQ_EMPTY($head2)) { *($head1)-> &tqh_last = ($head2)-> &tqh_first; ($head2)-> ($tqh_first->{field}->{tqe_prev}) = ($head1)-> &tqh_last; ($head1)-> &tqh_last = ($head2)-> &tqh_last;  &TAILQ_INIT(($head2)); } }  &while ( 0));
    }' unless defined(&TAILQ_CONCAT);
    eval 'sub STAILQ_HEAD {
        my($name, $type) = @_;
	    eval q(\'struct name\' { \'struct type\' * &stqh_first; \'struct type\' ** &stqh_last; });
    }' unless defined(&STAILQ_HEAD);
    eval 'sub STAILQ_HEAD_INITIALIZER {
        my($head) = @_;
	    eval q({  &NULL, ($head). &stqh_first });
    }' unless defined(&STAILQ_HEAD_INITIALIZER);
    eval 'sub STAILQ_ENTRY {
        my($type) = @_;
	    eval q(\'struct struct\' { \'struct type\' * &stqe_next; });
    }' unless defined(&STAILQ_ENTRY);
    eval 'sub STAILQ_FIRST {
        my($head) = @_;
	    eval q((($head)-> &stqh_first));
    }' unless defined(&STAILQ_FIRST);
    eval 'sub STAILQ_END {
        my($head) = @_;
	    eval q( &NULL);
    }' unless defined(&STAILQ_END);
    eval 'sub STAILQ_NEXT {
        my($elm, $field) = @_;
	    eval q((($elm)-> ($field->{stqe_next})));
    }' unless defined(&STAILQ_NEXT);
    eval 'sub STAILQ_EMPTY {
        my($head) = @_;
	    eval q(( &STAILQ_FIRST($head) ==  &STAILQ_END($head)));
    }' unless defined(&STAILQ_EMPTY);
    eval 'sub STAILQ_INIT {
        my($head) = @_;
	    eval q( &do { ($head)-> &stqh_first =  &NULL; ($head)-> &stqh_last = ($head)-> &stqh_first; }  &while ( 0));
    }' unless defined(&STAILQ_INIT);
    eval 'sub STAILQ_INSERT_HEAD {
        my($head, $elm, $field) = @_;
	    eval q( &do {  &if ((($elm)-> ($field->{stqe_next}) = ($head)-> &stqh_first) ==  &NULL) ($head)-> &stqh_last = ($elm)-> ($field->{stqe_next}); ($head)-> &stqh_first = ($elm); }  &while ( 0));
    }' unless defined(&STAILQ_INSERT_HEAD);
    eval 'sub STAILQ_INSERT_TAIL {
        my($head, $elm, $field) = @_;
	    eval q( &do { ($elm)-> ($field->{stqe_next}) =  &NULL; *($head)-> &stqh_last = ($elm); ($head)-> &stqh_last = ($elm)-> ($field->{stqe_next}); }  &while ( 0));
    }' unless defined(&STAILQ_INSERT_TAIL);
    eval 'sub STAILQ_INSERT_AFTER {
        my($head, $listelm, $elm, $field) = @_;
	    eval q( &do {  &if ((($elm)-> ($field->{stqe_next}) = ($listelm)-> ($field->{stqe_next})) ==  &NULL) ($head)-> &stqh_last = ($elm)-> ($field->{stqe_next}); ($listelm)-> ($field->{stqe_next}) = ($elm); }  &while ( 0));
    }' unless defined(&STAILQ_INSERT_AFTER);
    eval 'sub STAILQ_REMOVE_HEAD {
        my($head, $field) = @_;
	    eval q( &do {  &if ((($head)-> &stqh_first = ($head)-> ($stqh_first->{field}->{stqe_next})) ==  &NULL) ($head)-> &stqh_last = ($head)-> &stqh_first; }  &while ( 0));
    }' unless defined(&STAILQ_REMOVE_HEAD);
    eval 'sub STAILQ_REMOVE {
        my($head, $elm, $type, $field) = @_;
	    eval q( &do {  &if (($head)-> &stqh_first == ($elm)) {  &STAILQ_REMOVE_HEAD(($head), $field); }  &else { \'struct type\' * &curelm = ($head)-> &stqh_first;  &while ( ($curelm->{field}->{stqe_next}) != ($elm))  &curelm =  ($curelm->{field}->{stqe_next});  &if (( ($curelm->{field}->{stqe_next}) =  ($curelm->{field}->{stqe_next}->{field}->{stqe_next})) ==  &NULL) ($head)-> &stqh_last = ( &curelm)-> ($field->{stqe_next}); } }  &while ( 0));
    }' unless defined(&STAILQ_REMOVE);
    eval 'sub STAILQ_FOREACH {
        my($var, $head, $field) = @_;
	    eval q( &for (($var) = (($head)-> &stqh_first); ($var); ($var) = (($var)-> ($field->{stqe_next}))));
    }' unless defined(&STAILQ_FOREACH);
    eval 'sub STAILQ_FOREACH_SAFE {
        my($var, $head, $field, $tvar) = @_;
	    eval q( &for (($var) =  &STAILQ_FIRST(($head)); ($var)  && (($tvar) =  &STAILQ_NEXT(($var), $field), 1); ($var) = ($tvar)));
    }' unless defined(&STAILQ_FOREACH_SAFE);
    eval 'sub STAILQ_CONCAT {
        my($head1, $head2) = @_;
	    eval q( &do {  &if (! &STAILQ_EMPTY(($head2))) { *($head1)-> &stqh_last = ($head2)-> &stqh_first; ($head1)-> &stqh_last = ($head2)-> &stqh_last;  &STAILQ_INIT(($head2)); } }  &while ( 0));
    }' unless defined(&STAILQ_CONCAT);
    eval 'sub STAILQ_LAST {
        my($head, $type, $field) = @_;
	    eval q(( &STAILQ_EMPTY(($head)) ?  &NULL : (( &void *) ((($head)-> &stqh_last) -  &offsetof(\'struct type\', $field)))));
    }' unless defined(&STAILQ_LAST);
}
1;
