require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_NET_NET_STATS_H_)) {
    eval 'sub _NET_NET_STATS_H_ () {1;}' unless defined(&_NET_NET_STATS_H_);
    if(defined(&_KERNEL)) {
	require 'sys/percpu.ph';
	eval 'sub _NET_STAT_GETREF {
	    my($stat) = @_;
    	    eval q((( &net_stat_ref_t) &percpu_getref(($stat))));
	}' unless defined(&_NET_STAT_GETREF);
	eval 'sub _NET_STAT_PUTREF {
	    my($stat) = @_;
    	    eval q( &percpu_putref(($stat)));
	}' unless defined(&_NET_STAT_PUTREF);
	eval 'sub _NET_STATINC_REF {
	    my($r, $x) = @_;
    	    eval q( &do {  &uint64_t * &_stat_ = ($r);  $_stat_[$x]++; }  &while ( 0));
	}' unless defined(&_NET_STATINC_REF);
	eval 'sub _NET_STATINC {
	    my($stat, $x) = @_;
    	    eval q( &do {  &net_stat_ref_t  &_nsr_ =  &_NET_STAT_GETREF($stat);  &_NET_STATINC_REF( &_nsr_, $x);  &_NET_STAT_PUTREF($stat); }  &while ( 0));
	}' unless defined(&_NET_STATINC);
	eval 'sub _NET_STATDEC_REF {
	    my($r, $x) = @_;
    	    eval q( &do {  &uint64_t * &_stat_ = ($r);  $_stat_[$x]--; }  &while ( 0));
	}' unless defined(&_NET_STATDEC_REF);
	eval 'sub _NET_STATDEC {
	    my($stat, $x) = @_;
    	    eval q( &do {  &net_stat_ref_t  &_nsr_ =  &_NET_STAT_GETREF($stat);  &_NET_STATDEC_REF( &_nsr_, $x);  &_NET_STAT_PUTREF($stat); }  &while ( 0));
	}' unless defined(&_NET_STATDEC);
	eval 'sub _NET_STATADD_REF {
	    my($r, $x, $v) = @_;
    	    eval q( &do {  &uint64_t * &_stat_ = ($r);  $_stat_[$x] += ($v); }  &while ( 0));
	}' unless defined(&_NET_STATADD_REF);
	eval 'sub _NET_STATADD {
	    my($stat, $x, $v) = @_;
    	    eval q( &do {  &net_stat_ref_t  &_nsr_ =  &_NET_STAT_GETREF($stat);  &_NET_STATADD_REF( &_nsr_, $x, $v);  &_NET_STAT_PUTREF($stat); }  &while ( 0));
	}' unless defined(&_NET_STATADD);
	eval 'sub _NET_STATSUB_REF {
	    my($r, $x, $v) = @_;
    	    eval q( &do {  &uint64_t * &_stat_ = ($r);  $_stat_[$x] -= ($v); }  &while ( 0));
	}' unless defined(&_NET_STATSUB_REF);
	eval 'sub _NET_STATSUB {
	    my($stat, $x, $v) = @_;
    	    eval q( &do {  &net_stat_ref_t  &_nsr_ =  &_NET_STAT_GETREF($stat);  &_NET_STATSUB_REF( &_nsr_, $x, $v);  &_NET_STAT_PUTREF($stat); }  &while ( 0));
	}' unless defined(&_NET_STATSUB);
	eval 'sub NETSTAT_SYSCTL {
	    my($stat, $nctrs) = @_;
    	    eval q( &netstat_sysctl(($stat), ($nctrs),  &name,  &namelen,  &oldp,  &oldlenp,  &newp,  &newlen,  &oname,  &l,  &rnode));
	}' unless defined(&NETSTAT_SYSCTL);
    }
}
1;
