if (!defined &_SYS_QUEUE_H_) {
    eval 'sub _SYS_QUEUE_H_ {1;}';
    eval 'sub LIST_HEAD {
        local($name, $type) = @_;
        eval "struct name { \'struct type\' * &lh_first; }";
    }';
    eval 'sub LIST_ENTRY {
        local($type) = @_;
        eval "struct struct { \'struct type\' * &le_next; struct type ** &le_prev; }";
    }';
    eval 'sub LIST_INIT {
        local($head) = @_;
        eval "{ ($head)-> &lh_first =  &NULL; }";
    }';
    eval 'sub LIST_INSERT_AFTER {
        local($listelm, $elm, $field) = @_;
        eval "{  &if ((($elm)->$field. &le_next = ($listelm)->$field. &le_next) !=  &NULL) ($listelm)->$field. &le_next->$field. &le_prev = &($elm)->$field. &le_next; ($listelm)->$field. &le_next = ($elm); ($elm)->$field. &le_prev = &($listelm)->$field. &le_next; }";
    }';
    eval 'sub LIST_INSERT_HEAD {
        local($head, $elm, $field) = @_;
        eval "{  &if ((($elm)->$field. &le_next = ($head)-> &lh_first) !=  &NULL) ($head)-> &lh_first->$field. &le_prev = &($elm)->$field. &le_next; ($head)-> &lh_first = ($elm); ($elm)->$field. &le_prev = &($head)-> &lh_first; }";
    }';
    eval 'sub LIST_REMOVE {
        local($elm, $field) = @_;
        eval "{  &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; }";
    }';
    eval 'sub TAILQ_HEAD {
        local($name, $type) = @_;
        eval "struct name { \'struct type\' * &tqh_first; struct type ** &tqh_last; }";
    }';
    eval 'sub TAILQ_ENTRY {
        local($type) = @_;
        eval "struct struct { \'struct type\' * &tqe_next; struct type ** &tqe_prev; }";
    }';
    eval 'sub TAILQ_INIT {
        local($head) = @_;
        eval "{ ($head)-> &tqh_first =  &NULL; ($head)-> &tqh_last = &($head)-> &tqh_first; }";
    }';
    eval 'sub TAILQ_INSERT_HEAD {
        local($head, $elm, $field) = @_;
        eval "{  &if ((($elm)->$field. &tqe_next = ($head)-> &tqh_first) !=  &NULL) ($elm)->$field. &tqe_next->$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; }";
    }';
    eval 'sub TAILQ_INSERT_TAIL {
        local($head, $elm, $field) = @_;
        eval "{ ($elm)->$field. &tqe_next =  &NULL; ($elm)->$field. &tqe_prev = ($head)-> &tqh_last; *($head)-> &tqh_last = ($elm); ($head)-> &tqh_last = &($elm)->$field. &tqe_next; }";
    }';
    eval 'sub TAILQ_INSERT_AFTER {
        local($head, $listelm, $elm, $field) = @_;
        eval "{  &if ((($elm)->$field. &tqe_next = ($listelm)->$field. &tqe_next) !=  &NULL) ($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; }";
    }';
    eval 'sub TAILQ_REMOVE {
        local($head, $elm, $field) = @_;
        eval "{  &if ((($elm)->$field. &tqe_next) !=  &NULL) ($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; }";
    }';
    eval 'sub CIRCLEQ_HEAD {
        local($name, $type) = @_;
        eval "struct name { \'struct type\' * &cqh_first; struct type * &cqh_last; }";
    }';
    eval 'sub CIRCLEQ_ENTRY {
        local($type) = @_;
        eval "struct struct { \'struct type\' * &cqe_next; struct type * &cqe_prev; }";
    }';
    eval 'sub CIRCLEQ_INIT {
        local($head) = @_;
        eval "{ ($head)-> &cqh_first = ( &void *)($head); ($head)-> &cqh_last = ( &void *)($head); }";
    }';
    eval 'sub CIRCLEQ_INSERT_AFTER {
        local($head, $listelm, $elm, $field) = @_;
        eval "{ ($elm)->$field. &cqe_next = ($listelm)->$field. &cqe_next; ($elm)->$field. &cqe_prev = ($listelm);  &if (($listelm)->$field. &cqe_next == ( &void *)($head)) ($head)-> &cqh_last = ($elm);  &else ($listelm)->$field. &cqe_next->$field. &cqe_prev = ($elm); ($listelm)->$field. &cqe_next = ($elm); }";
    }';
    eval 'sub CIRCLEQ_INSERT_BEFORE {
        local($head, $listelm, $elm, $field) = @_;
        eval "{ ($elm)->$field. &cqe_next = ($listelm); ($elm)->$field. &cqe_prev = ($listelm)->$field. &cqe_prev;  &if (($listelm)->$field. &cqe_prev == ( &void *)($head)) ($head)-> &cqh_first = ($elm);  &else ($listelm)->$field. &cqe_prev->$field. &cqe_next = ($elm); ($listelm)->$field. &cqe_prev = ($elm); }";
    }';
    eval 'sub CIRCLEQ_INSERT_HEAD {
        local($head, $elm, $field) = @_;
        eval "{ ($elm)->$field. &cqe_next = ($head)-> &cqh_first; ($elm)->$field. &cqe_prev = ( &void *)($head);  &if (($head)-> &cqh_last == ( &void *)($head)) ($head)-> &cqh_last = ($elm);  &else ($head)-> &cqh_first->$field. &cqe_prev = ($elm); ($head)-> &cqh_first = ($elm); }";
    }';
    eval 'sub CIRCLEQ_INSERT_TAIL {
        local($head, $elm, $field) = @_;
        eval "{ ($elm)->$field. &cqe_next = ( &void *)($head); ($elm)->$field. &cqe_prev = ($head)-> &cqh_last;  &if (($head)-> &cqh_first == ( &void *)($head)) ($head)-> &cqh_first = ($elm);  &else ($head)-> &cqh_last->$field. &cqe_next = ($elm); ($head)-> &cqh_last = ($elm); }";
    }';
    eval 'sub CIRCLEQ_REMOVE {
        local($head, $elm, $field) = @_;
        eval "{  &if (($elm)->$field. &cqe_next == ( &void *)($head)) ($head)-> &cqh_last = ($elm)->$field. &cqe_prev;  &else ($elm)->$field. &cqe_next->$field. &cqe_prev = ($elm)->$field. &cqe_prev;  &if (($elm)->$field. &cqe_prev == ( &void *)($head)) ($head)-> &cqh_first = ($elm)->$field. &cqe_next;  &else ($elm)->$field. &cqe_prev->$field. &cqe_next = ($elm)->$field. &cqe_next; }";
    }';
}
1;
