require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_RPC_TYPES_H_)) {
    eval 'sub _RPC_TYPES_H_ () {1;}' unless defined(&_RPC_TYPES_H_);
    require 'sys/types.ph';
    eval 'sub __dontcare__ () {-1;}' unless defined(&__dontcare__);
    unless(defined(&FALSE)) {
	eval 'sub FALSE () {(0);}' unless defined(&FALSE);
    }
    unless(defined(&TRUE)) {
	eval 'sub TRUE () {(1);}' unless defined(&TRUE);
    }
    unless(defined(&NULL)) {
	eval 'sub NULL () {0;}' unless defined(&NULL);
    }
    if(defined(&_KERNEL) || defined(&_STANDALONE)) {
	eval 'sub warn () {( &msg,...);}' unless defined(&warn);
	require 'sys/kmem.ph';
	eval 'sub mem_alloc {
	    my($bsize) = @_;
    	    eval q( &kmem_alloc($bsize,  &KM_SLEEP));
	}' unless defined(&mem_alloc);
	eval 'sub mem_free {
	    my($ptr, $bsize) = @_;
    	    eval q( &kmem_free($ptr, $bsize));
	}' unless defined(&mem_free);
    } else {
	eval 'sub mem_alloc {
	    my($bsize) = @_;
    	    eval q( &calloc(1, $bsize));
	}' unless defined(&mem_alloc);
	eval 'sub mem_free {
	    my($ptr, $bsize) = @_;
    	    eval q( &free($ptr));
	}' unless defined(&mem_free);
	require 'sys/time.ph';
	require 'netconfig.ph';
    }
}
1;
