require '_h2ph_pre.ph';

unless(defined(&_LINUX_LIST_H)) {
    eval 'sub _LINUX_LIST_H () {1;}' unless defined(&_LINUX_LIST_H);
    if(defined( &__KERNEL__) || defined( &_LVM_H_INCLUDE)) {
	require 'linux/prefetch.ph';
	eval 'sub LIST_HEAD_INIT {
	    local($name) = @_;
    	    eval q({ ($name), ($name) });
	}' unless defined(&LIST_HEAD_INIT);
	eval 'sub LIST_HEAD {
	    local($name) = @_;
    	    eval q(\'struct list_head\' $name =  &LIST_HEAD_INIT($name));
	}' unless defined(&LIST_HEAD);
	eval 'sub INIT_LIST_HEAD {
	    local($ptr) = @_;
    	    eval q( &do { ($ptr)-> &next = ($ptr); ($ptr)-> &prev = ($ptr); }  &while (0));
	}' unless defined(&INIT_LIST_HEAD);
	eval 'sub list_entry {
	    local($ptr, $type, $member) = @_;
    	    eval q(((-((0)->$member))));
	}' unless defined(&list_entry);
	eval 'sub list_for_each {
	    local($pos, $head) = @_;
    	    eval q( &for ($pos = ($head)-> &next,  &prefetch( ($pos->{next})); $pos != ($head); $pos =  ($pos->{next}),  &prefetch( ($pos->{next}))));
	}' unless defined(&list_for_each);
	eval 'sub list_for_each_safe {
	    local($pos, $n, $head) = @_;
    	    eval q( &for ($pos = ($head)-> &next, $n =  ($pos->{next}); $pos != ($head); $pos = $n, $n =  ($pos->{next})));
	}' unless defined(&list_for_each_safe);
    }
}
1;
