require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_MALLOC_H_)) {
    eval 'sub _SYS_MALLOC_H_ () {1;}' unless defined(&_SYS_MALLOC_H_);
    if(defined(&_KERNEL)) {
	eval 'sub M_WAITOK () {0x;}' unless defined(&M_WAITOK);
	eval 'sub M_NOWAIT () {0x1;}' unless defined(&M_NOWAIT);
	eval 'sub M_ZERO () {0x2;}' unless defined(&M_ZERO);
	require 'sys/mallocvar.ph';
	if(0) {
	}
	eval 'sub malloc {
	    my($size, $type, $flags) = @_;
    	    eval q( &kern_malloc($size, $flags));
	}' unless defined(&malloc);
	eval 'sub free {
	    my($addr, $type) = @_;
    	    eval q( &kern_free($addr));
	}' unless defined(&free);
	eval 'sub realloc {
	    my($ptr, $size, $type, $flags) = @_;
    	    eval q( &kern_realloc($ptr, $size, $flags));
	}' unless defined(&realloc);
    }
}
1;
