require '_h2ph_pre.ph';

no warnings qw(redefine misc);

if(defined(&_KERNEL)) {
    die("rump_syscalls_compat\ is\ not\ for\ kernel\ consumers");
}
unless(defined(&_RUMP_RUMP_SYSCALLS_COMPAT_H_)) {
    eval 'sub _RUMP_RUMP_SYSCALLS_COMPAT_H_ () {1;}' unless defined(&_RUMP_RUMP_SYSCALLS_COMPAT_H_);
    unless(defined(&RUMP_HOST_NOT_POSIX)) {
	require 'sys/types.ph';
	require 'sys/select.ph';
	require 'sys/socket.ph';
	require 'signal.ph';
    }
    if(defined(&__NetBSD__)) {
	require 'sys/cdefs.ph';
	require 'sys/param.ph';
	if(! &__NetBSD_Prereq__(5,99,7)) {
	    eval 'sub RUMP_SYS_RENAME_STAT () { &rump___sysimpl_stat30;}' unless defined(&RUMP_SYS_RENAME_STAT);
	    eval 'sub RUMP_SYS_RENAME_FSTAT () { &rump___sysimpl_fstat30;}' unless defined(&RUMP_SYS_RENAME_FSTAT);
	    eval 'sub RUMP_SYS_RENAME_LSTAT () { &rump___sysimpl_lstat30;}' unless defined(&RUMP_SYS_RENAME_LSTAT);
	    eval 'sub RUMP_SYS_RENAME_POLLTS () { &rump___sysimpl_pollts;}' unless defined(&RUMP_SYS_RENAME_POLLTS);
	    eval 'sub RUMP_SYS_RENAME_SELECT () { &rump___sysimpl_select;}' unless defined(&RUMP_SYS_RENAME_SELECT);
	    eval 'sub RUMP_SYS_RENAME_PSELECT () { &rump___sysimpl_pselect;}' unless defined(&RUMP_SYS_RENAME_PSELECT);
	    eval 'sub RUMP_SYS_RENAME_KEVENT () { &rump___sysimpl_kevent;}' unless defined(&RUMP_SYS_RENAME_KEVENT);
	    eval 'sub RUMP_SYS_RENAME_UTIMES () { &rump___sysimpl_utimes;}' unless defined(&RUMP_SYS_RENAME_UTIMES);
	    eval 'sub RUMP_SYS_RENAME_FUTIMES () { &rump___sysimpl_futimes;}' unless defined(&RUMP_SYS_RENAME_FUTIMES);
	    eval 'sub RUMP_SYS_RENAME_LUTIMES () { &rump___sysimpl_lutimes;}' unless defined(&RUMP_SYS_RENAME_LUTIMES);
	    eval 'sub RUMP_SYS_RENAME_MKNOD () { &rump___sysimpl_mknod;}' unless defined(&RUMP_SYS_RENAME_MKNOD);
	    eval 'sub RUMP_SYS_RENAME_FHSTAT () { &rump___sysimpl_fhstat40;}' unless defined(&RUMP_SYS_RENAME_FHSTAT);
	}
    } else {
	unless(defined(&__RENAME)) {
	    if(defined(&__ELF__)) {
		eval 'sub __RUMPSTRINGIFY {
		    my($x) = @_;
    		    eval q($x);
		}' unless defined(&__RUMPSTRINGIFY);
	    } else {
		eval 'sub __RUMPSTRINGIFY {
		    my($x) = @_;
    		    eval q(\\"_\\"$x);
		}' unless defined(&__RUMPSTRINGIFY);
	    }
	    eval 'sub __RENAME {
	        my($x) = @_;
    		eval q( &__asm( &__RUMPSTRINGIFY($x)));
	    }' unless defined(&__RENAME);
	}
    }
}
1;
