require '_h2ph_pre.ph';

unless(defined(&_UVM_UVM_STAT_H_)) {
    eval 'sub _UVM_UVM_STAT_H_ () {1;}' unless defined(&_UVM_UVM_STAT_H_);
    require 'sys/queue.ph';
    eval 'sub UVMCNT_MASK () {0xf;}' unless defined(&UVMCNT_MASK);
    eval 'sub UVMCNT_CNT () {0;}' unless defined(&UVMCNT_CNT);
    eval 'sub UVMCNT_DEV () {1;}' unless defined(&UVMCNT_DEV);
    eval 'sub UVMCNT_INIT {
        local($CNT,$TYP,$VAL,$NAM,$PRIV) = @_;
	    eval q( &do {  ($CNT->{c}) = $VAL;  ($CNT->{t}) = $TYP;  ($CNT->{next}) =  &uvm_cnt_head;  &uvm_cnt_head = $CNT;  ($CNT->{name}) = $NAM;  ($CNT->{p}) = $PRIV; }  &while (0));
    }' unless defined(&UVMCNT_INIT);
    eval 'sub UVMCNT_SET {
        local($C,$V) = @_;
	    eval q( &do { ($C). &c = ($V); }  &while (0));
    }' unless defined(&UVMCNT_SET);
    eval 'sub UVMCNT_ADD {
        local($C,$V) = @_;
	    eval q( &do { ($C). &c += ($V); }  &while (0));
    }' unless defined(&UVMCNT_ADD);
    eval 'sub UVMCNT_INCR {
        local($C) = @_;
	    eval q( &UVMCNT_ADD($C,1));
    }' unless defined(&UVMCNT_INCR);
    eval 'sub UVMCNT_DECR {
        local($C) = @_;
	    eval q( &UVMCNT_ADD($C,-1));
    }' unless defined(&UVMCNT_DECR);
    eval 'sub MAXHISTS () {32;}' unless defined(&MAXHISTS);
    eval 'sub UVMHIST_MAPHIST () {0x00000001;}' unless defined(&UVMHIST_MAPHIST);
    eval 'sub UVMHIST_PDHIST () {0x00000002;}' unless defined(&UVMHIST_PDHIST);
    unless(defined(&UVMHIST)) {
	eval 'sub UVMHIST_DECL {
	    local($NAME) = @_;
    	    eval q();
	}' unless defined(&UVMHIST_DECL);
	eval 'sub UVMHIST_INIT {
	    local($NAME,$N) = @_;
    	    eval q();
	}' unless defined(&UVMHIST_INIT);
	eval 'sub UVMHIST_INIT_STATIC {
	    local($NAME,$BUF) = @_;
    	    eval q();
	}' unless defined(&UVMHIST_INIT_STATIC);
	eval 'sub UVMHIST_LOG {
	    local($NAME,$FMT,$A,$B,$C,$D) = @_;
    	    eval q();
	}' unless defined(&UVMHIST_LOG);
	eval 'sub UVMHIST_CALLED {
	    local($NAME) = @_;
    	    eval q();
	}' unless defined(&UVMHIST_CALLED);
	eval 'sub UVMHIST_FUNC {
	    local($FNAME) = @_;
    	    eval q();
	}' unless defined(&UVMHIST_FUNC);
	eval 'sub uvmhist_dump {
	    local($NAME) = @_;
    	    eval q();
	}' unless defined(&uvmhist_dump);
    } else {
	eval 'sub UVMHIST_DECL {
	    local($NAME) = @_;
    	    eval q(\'struct uvm_history\' $NAME);
	}' unless defined(&UVMHIST_DECL);
	eval 'sub UVMHIST_INIT {
	    local($NAME,$N) = @_;
    	    eval q( &do { . &name =  &__STRING; . &namelen =  &strlen(. &name); . &n = ; . &f = 0;  &simple_lock_init(&. &l); . &e =  &malloc($sizeof{\'struct uvm_history_ent\'} * ($N),  &M_TEMP,  &M_WAITOK);  &bzero(($NAME). &e, $sizeof{\'struct uvm_history_ent\'} * ($N));  &LIST_INSERT_HEAD( &uvm_histories, ($NAME),  &list); }  &while (0));
	}' unless defined(&UVMHIST_INIT);
	eval 'sub UVMHIST_INIT_STATIC {
	    local($NAME,$BUF) = @_;
    	    eval q( &do { . &name =  &__STRING; . &namelen =  &strlen(. &name); . &n =  &sizeof /  &sizeof; . &f = 0;  &simple_lock_init(&. &l); . &e = ($BUF);  &bzero(($NAME). &e, $sizeof{\'struct uvm_history_ent\'} * ($NAME). &n);  &LIST_INSERT_HEAD( &uvm_histories, ($NAME),  &list); }  &while (0));
	}' unless defined(&UVMHIST_INIT_STATIC);
	if(defined( &UVMHIST_PRINT)) {
	    eval 'sub UVMHIST_PRINTNOW {
	        local($E) = @_;
    		eval q( &do {  &if ( &uvmhist_print_enabled) {  &uvmhist_print($E);  &DELAY(100000); } }  &while (0));
	    }' unless defined(&UVMHIST_PRINTNOW);
	} else {
	    eval 'sub UVMHIST_PRINTNOW {
	        local($E) = @_;
    		eval q();
	    }' unless defined(&UVMHIST_PRINTNOW);
	}
	eval 'sub UVMHIST_LOG {
	    local($NAME,$FMT,$A,$B,$C,$D) = @_;
    	    eval q( &do {  &register \'int\'  &i,  &s =  &splhigh();  &simple_lock(&. &l);  &i = . &f; . &f = ( &i + 1) % . &n;  &simple_unlock(&. &l);  &splx;  &if (! &cold)  &microtime(&. ($e[&i]->{tv})); . ($e[&i]->{fmt}) = ; . ($e[&i]->{fmtlen}) =  &strlen(. ($e[&i]->{fmt})); . ($e[&i]->{fn}) =  &_uvmhist_name; . ($e[&i]->{fnlen}) =  &strlen(. ($e[&i]->{fn})); . ($e[&i]->{call}) =  &_uvmhist_call; . ($e[&i]->{v[0]}) = ; . ($e[&i]->{v[1]}) = ; . ($e[&i]->{v[2]}) = ; . ($e[&i]->{v[3]}) = ($D);  &UVMHIST_PRINTNOW((($NAME). $e[ &i])); }  &while (0));
	}' unless defined(&UVMHIST_LOG);
	eval 'sub UVMHIST_CALLED {
	    local($NAME) = @_;
    	    eval q( &do { { \'int\'  &s =  &splhigh();  &simple_lock(($NAME). &l);  &_uvmhist_call =  &_uvmhist_cnt++;  &simple_unlock(($NAME). &l);  &splx( &s); }  &UVMHIST_LOG($NAME,\\"called!\\", 0, 0, 0, 0); }  &while (0));
	}' unless defined(&UVMHIST_CALLED);
	eval 'sub UVMHIST_FUNC {
	    local($FNAME) = @_;
    	    eval q( &static \'int\'  &_uvmhist_cnt = 0;  &static \'char\' * &_uvmhist_name = $FNAME; \'int\'  &_uvmhist_call;);
	}' unless defined(&UVMHIST_FUNC);
    }
}
1;
