require '_h2ph_pre.ph';

unless(defined(&_LINUX_HIGHUID_H)) {
    eval 'sub _LINUX_HIGHUID_H () {1;}' unless defined(&_LINUX_HIGHUID_H);
    require 'linux/config.ph';
    require 'linux/types.ph';
    eval 'sub DEFAULT_OVERFLOWUID () {65534;}' unless defined(&DEFAULT_OVERFLOWUID);
    eval 'sub DEFAULT_OVERFLOWGID () {65534;}' unless defined(&DEFAULT_OVERFLOWGID);
    if(defined(&CONFIG_UID16)) {
	eval 'sub high2lowuid {
	    local($uid) = @_;
    	    eval q(( > 65535?  &overflowuid : ($uid)));
	}' unless defined(&high2lowuid);
	eval 'sub high2lowgid {
	    local($gid) = @_;
    	    eval q(( > 65535?  &overflowgid : ($gid)));
	}' unless defined(&high2lowgid);
	eval 'sub low2highuid {
	    local($uid) = @_;
    	    eval q(( == -1? -1: ($uid)));
	}' unless defined(&low2highuid);
	eval 'sub low2highgid {
	    local($gid) = @_;
    	    eval q(( == -1? -1: ($gid)));
	}' unless defined(&low2highgid);
	eval 'sub SET_UID16 {
	    local($var, $uid) = @_;
    	    eval q($var =  &high2lowuid($uid));
	}' unless defined(&SET_UID16);
	eval 'sub SET_GID16 {
	    local($var, $gid) = @_;
    	    eval q($var =  &high2lowgid($gid));
	}' unless defined(&SET_GID16);
	eval 'sub NEW_TO_OLD_UID {
	    local($uid) = @_;
    	    eval q( &high2lowuid($uid));
	}' unless defined(&NEW_TO_OLD_UID);
	eval 'sub NEW_TO_OLD_GID {
	    local($gid) = @_;
    	    eval q( &high2lowgid($gid));
	}' unless defined(&NEW_TO_OLD_GID);
	eval 'sub SET_OLDSTAT_UID {
	    local($stat, $uid) = @_;
    	    eval q(($stat). &st_uid =  &high2lowuid($uid));
	}' unless defined(&SET_OLDSTAT_UID);
	eval 'sub SET_OLDSTAT_GID {
	    local($stat, $gid) = @_;
    	    eval q(($stat). &st_gid =  &high2lowgid($gid));
	}' unless defined(&SET_OLDSTAT_GID);
	eval 'sub SET_STAT_UID {
	    local($stat, $uid) = @_;
    	    eval q(($stat). &st_uid =  &high2lowuid($uid));
	}' unless defined(&SET_STAT_UID);
	eval 'sub SET_STAT_GID {
	    local($stat, $gid) = @_;
    	    eval q(($stat). &st_gid =  &high2lowgid($gid));
	}' unless defined(&SET_STAT_GID);
    } else {
	eval 'sub SET_UID16 {
	    local($var, $uid) = @_;
    	    eval q( &do { ; }  &while (0));
	}' unless defined(&SET_UID16);
	eval 'sub SET_GID16 {
	    local($var, $gid) = @_;
    	    eval q( &do { ; }  &while (0));
	}' unless defined(&SET_GID16);
	eval 'sub NEW_TO_OLD_UID {
	    local($uid) = @_;
    	    eval q(($uid));
	}' unless defined(&NEW_TO_OLD_UID);
	eval 'sub NEW_TO_OLD_GID {
	    local($gid) = @_;
    	    eval q(($gid));
	}' unless defined(&NEW_TO_OLD_GID);
	eval 'sub SET_OLDSTAT_UID {
	    local($stat, $uid) = @_;
    	    eval q(($stat). &st_uid = ($uid));
	}' unless defined(&SET_OLDSTAT_UID);
	eval 'sub SET_OLDSTAT_GID {
	    local($stat, $gid) = @_;
    	    eval q(($stat). &st_gid = ($gid));
	}' unless defined(&SET_OLDSTAT_GID);
	eval 'sub SET_STAT_UID {
	    local($stat, $uid) = @_;
    	    eval q(($stat). &st_uid = ($uid));
	}' unless defined(&SET_STAT_UID);
	eval 'sub SET_STAT_GID {
	    local($stat, $gid) = @_;
    	    eval q(($stat). &st_gid = ($gid));
	}' unless defined(&SET_STAT_GID);
    }
    eval 'sub DEFAULT_FS_OVERFLOWUID () {65534;}' unless defined(&DEFAULT_FS_OVERFLOWUID);
    eval 'sub DEFAULT_FS_OVERFLOWGID () {65534;}' unless defined(&DEFAULT_FS_OVERFLOWGID);
    eval 'sub fs_high2lowuid {
        local($uid) = @_;
	    eval q(( > 65535?  &fs_overflowuid : ($uid)));
    }' unless defined(&fs_high2lowuid);
    eval 'sub fs_high2lowgid {
        local($gid) = @_;
	    eval q(( > 65535?  &fs_overflowgid : ($gid)));
    }' unless defined(&fs_high2lowgid);
    eval 'sub low_16_bits {
        local($x) = @_;
	    eval q((($x) & 0xffff));
    }' unless defined(&low_16_bits);
    eval 'sub high_16_bits {
        local($x) = @_;
	    eval q(((($x) & 0xffff0000) >> 16));
    }' unless defined(&high_16_bits);
}
1;
