require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_RUMP_RUMP_SYSCALLSHOTGUN_H_)) {
    eval 'sub _RUMP_RUMP_SYSCALLSHOTGUN_H_ () {1;}' unless defined(&_RUMP_RUMP_SYSCALLSHOTGUN_H_);
    if(defined(&RUMP_SYS_NETWORKING)) {
	require 'sys/socket.ph';
	eval 'sub socket {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_socket($a,$b,$c));
	}' unless defined(&socket);
	eval 'sub accept {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_accept($a,$b,$c));
	}' unless defined(&accept);
	eval 'sub bind {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_bind($a,$b,$c));
	}' unless defined(&bind);
	eval 'sub connect {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_connect($a,$b,$c));
	}' unless defined(&connect);
	eval 'sub getpeername {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_getpeername($a,$b,$c));
	}' unless defined(&getpeername);
	eval 'sub getsockname {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_getsockname($a,$b,$c));
	}' unless defined(&getsockname);
	eval 'sub listen {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_listen($a,$b));
	}' unless defined(&listen);
	eval 'sub recvfrom {
	    my($a,$b,$c,$d,$e,$f) = @_;
    	    eval q( &rump_sys_recvfrom($a,$b,$c,$d,$e,$f));
	}' unless defined(&recvfrom);
	eval 'sub recvmsg {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_recvmsg($a,$b,$c));
	}' unless defined(&recvmsg);
	eval 'sub sendto {
	    my($a,$b,$c,$d,$e,$f) = @_;
    	    eval q( &rump_sys_sendto($a,$b,$c,$d,$e,$f));
	}' unless defined(&sendto);
	eval 'sub sendmsg {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_sendmsg($a,$b,$c));
	}' unless defined(&sendmsg);
	eval 'sub getsockopt {
	    my($a,$b,$c,$d,$e) = @_;
    	    eval q( &rump_sys_getsockopt($a,$b,$c,$d,$e));
	}' unless defined(&getsockopt);
	eval 'sub setsockopt {
	    my($a,$b,$c,$d,$e) = @_;
    	    eval q( &rump_sys_setsockopt($a,$b,$c,$d,$e));
	}' unless defined(&setsockopt);
	eval 'sub shutdown {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_shutdown($a,$b));
	}' unless defined(&shutdown);
    }
    if(defined(&RUMP_SYS_IOCTL)) {
	require 'sys/ioctl.ph';
	eval 'sub ioctl () {(...)  &rump_sys_ioctl( &__VA_ARGS__);}' unless defined(&ioctl);
	eval 'sub fcntl () {(...)  &rump_sys_fcntl( &__VA_ARGS__);}' unless defined(&fcntl);
    }
    if(defined(&RUMP_SYS_CLOSE)) {
	require 'fcntl.ph';
	eval 'sub close {
	    my($a) = @_;
    	    eval q( &rump_sys_close($a));
	}' unless defined(&close);
    }
    if(defined(&RUMP_SYS_OPEN)) {
	require 'fcntl.ph';
	eval 'sub open () {(...)  &rump_sys_open( &__VA_ARGS__);}' unless defined(&open);
    }
    if(defined(&RUMP_SYS_READWRITE)) {
	require 'fcntl.ph';
	eval 'sub read {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_read($a,$b,$c));
	}' unless defined(&read);
	eval 'sub readv {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_readv($a,$b,$c));
	}' unless defined(&readv);
	eval 'sub pread {
	    my($a,$b,$c,$d) = @_;
    	    eval q( &rump_sys_pread($a,$b,$c,$d));
	}' unless defined(&pread);
	eval 'sub preadv {
	    my($a,$b,$c,$d) = @_;
    	    eval q( &rump_sys_preadv($a,$b,$c,$d));
	}' unless defined(&preadv);
	eval 'sub write {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_write($a,$b,$c));
	}' unless defined(&write);
	eval 'sub writev {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_writev($a,$b,$c));
	}' unless defined(&writev);
	eval 'sub pwrite {
	    my($a,$b,$c,$d) = @_;
    	    eval q( &rump_sys_pwrite($a,$b,$c,$d));
	}' unless defined(&pwrite);
	eval 'sub pwritev {
	    my($a,$b,$c,$d) = @_;
    	    eval q( &rump_sys_pwritev($a,$b,$c,$d));
	}' unless defined(&pwritev);
    }
    if(defined(&RUMP_SYS_FILEOPS)) {
	require 'stdlib.ph';
	require 'unistd.ph';
	eval 'sub mkdir {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_mkdir($a,$b));
	}' unless defined(&mkdir);
	eval 'sub rmdir {
	    my($a) = @_;
    	    eval q( &rump_sys_rmdir($a));
	}' unless defined(&rmdir);
	eval 'sub link {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_link($a,$b));
	}' unless defined(&link);
	eval 'sub symlink {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_symlink($a,$b));
	}' unless defined(&symlink);
	eval 'sub unlink {
	    my($a) = @_;
    	    eval q( &rump_sys_unlink($a));
	}' unless defined(&unlink);
	eval 'sub readlink {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_readlink($a,$b,$c));
	}' unless defined(&readlink);
	eval 'sub chdir {
	    my($a) = @_;
    	    eval q( &rump_sys_chdir($a));
	}' unless defined(&chdir);
	eval 'sub fsync {
	    my($a) = @_;
    	    eval q( &rump_sys_fsync($a));
	}' unless defined(&fsync);
	eval 'sub sync () {
	    eval q( &rump_sys_sync());
	}' unless defined(&sync);
	eval 'sub chown {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_chown($a,$b,$c));
	}' unless defined(&chown);
	eval 'sub fchown {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_fchown($a,$b,$c));
	}' unless defined(&fchown);
	eval 'sub lchown {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_lchown($a,$b,$c));
	}' unless defined(&lchown);
	eval 'sub lseek {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_lseek($a,$b,$c));
	}' unless defined(&lseek);
	eval 'sub mknod {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_mknod($a,$b,$c));
	}' unless defined(&mknod);
	eval 'sub rename {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_rename($a,$b));
	}' unless defined(&rename);
	eval 'sub truncate {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_truncate($a,$b));
	}' unless defined(&truncate);
	eval 'sub ftruncate {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_ftruncate($a,$b));
	}' unless defined(&ftruncate);
	eval 'sub umask {
	    my($a) = @_;
    	    eval q( &rump_sys_umask($a));
	}' unless defined(&umask);
	eval 'sub getdents {
	    my($a,$b,$c) = @_;
    	    eval q( &rump_sys_getdents($a,$b,$c));
	}' unless defined(&getdents);
    }
    if(defined(&RUMP_SYS_STAT)) {
	require 'sys/stat.ph';
	eval 'sub stat {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_stat($a,$b));
	}' unless defined(&stat);
	eval 'sub fstat {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_fstat($a,$b));
	}' unless defined(&fstat);
	eval 'sub lstat {
	    my($a,$b) = @_;
    	    eval q( &rump_sys_lstat($a,$b));
	}' unless defined(&lstat);
    }
    if(defined(&RUMP_SYS_PROCOPS)) {
	require 'unistd.ph';
	eval 'sub getpid () {
	    eval q( &rump_sys_getpid());
	}' unless defined(&getpid);
    }
}
1;
