require '_h2ph_pre.ph';

unless(defined(&_SYS_WAIT_H_)) {
    eval 'sub _SYS_WAIT_H_ () {1;}' unless defined(&_SYS_WAIT_H_);
    if(defined(&_POSIX_SOURCE)) {
	eval 'sub _W_INT {
	    local($i) = @_;
    	    eval q(($i));
	}' unless defined(&_W_INT);
    } else {
	eval 'sub _W_INT {
	    local($w) = @_;
    	    eval q((*($w)));
	}' unless defined(&_W_INT);
	eval 'sub WCOREFLAG () {0200;}' unless defined(&WCOREFLAG);
    }
    eval 'sub _WSTATUS {
        local($x) = @_;
	    eval q(( &_W_INT($x) & 0177));
    }' unless defined(&_WSTATUS);
    eval 'sub _WSTOPPED () {0177;}' unless defined(&_WSTOPPED);
    eval 'sub WIFSTOPPED {
        local($x) = @_;
	    eval q(( &_WSTATUS($x) ==  &_WSTOPPED));
    }' unless defined(&WIFSTOPPED);
    eval 'sub WSTOPSIG {
        local($x) = @_;
	    eval q(( &_W_INT($x) >> 8));
    }' unless defined(&WSTOPSIG);
    eval 'sub WIFSIGNALED {
        local($x) = @_;
	    eval q(( &_WSTATUS($x) !=  &_WSTOPPED  &&  &_WSTATUS($x) != 0));
    }' unless defined(&WIFSIGNALED);
    eval 'sub WTERMSIG {
        local($x) = @_;
	    eval q(( &_WSTATUS($x)));
    }' unless defined(&WTERMSIG);
    eval 'sub WIFEXITED {
        local($x) = @_;
	    eval q(( &_WSTATUS($x) == 0));
    }' unless defined(&WIFEXITED);
    eval 'sub WEXITSTATUS {
        local($x) = @_;
	    eval q(( &_W_INT($x) >> 8));
    }' unless defined(&WEXITSTATUS);
    unless(defined(&_POSIX_SOURCE)) {
	eval 'sub WCOREDUMP {
	    local($x) = @_;
    	    eval q(( &_W_INT($x) &  &WCOREFLAG));
	}' unless defined(&WCOREDUMP);
	eval 'sub W_EXITCODE {
	    local($ret, $sig) = @_;
    	    eval q((($ret) << 8| ($sig)));
	}' unless defined(&W_EXITCODE);
	eval 'sub W_STOPCODE {
	    local($sig) = @_;
    	    eval q((($sig) << 8|  &_WSTOPPED));
	}' unless defined(&W_STOPCODE);
    }
    eval 'sub WNOHANG () {1;}' unless defined(&WNOHANG);
    eval 'sub WUNTRACED () {2;}' unless defined(&WUNTRACED);
    unless(defined(&_POSIX_SOURCE)) {
	eval 'sub WALTSIG () {4;}' unless defined(&WALTSIG);
    }
    unless(defined(&_POSIX_SOURCE)) {
	eval 'sub WAIT_ANY () {(-1);}' unless defined(&WAIT_ANY);
	eval 'sub WAIT_MYPGRP () {0;}' unless defined(&WAIT_MYPGRP);
	require 'sys/types.ph';
	if((defined(&BYTE_ORDER) ? &BYTE_ORDER : 0) == (defined(&LITTLE_ENDIAN) ? &LITTLE_ENDIAN : 0)) {
	}
	if((defined(&BYTE_ORDER) ? &BYTE_ORDER : 0) == (defined(&BIG_ENDIAN) ? &BIG_ENDIAN : 0)) {
	}
	if((defined(&BYTE_ORDER) ? &BYTE_ORDER : 0) == (defined(&LITTLE_ENDIAN) ? &LITTLE_ENDIAN : 0)) {
	}
	if((defined(&BYTE_ORDER) ? &BYTE_ORDER : 0) == (defined(&BIG_ENDIAN) ? &BIG_ENDIAN : 0)) {
	}
	eval 'sub w_termsig () { ($w_T->{w_Termsig});}' unless defined(&w_termsig);
	eval 'sub w_coredump () { ($w_T->{w_Coredump});}' unless defined(&w_coredump);
	eval 'sub w_retcode () { ($w_T->{w_Retcode});}' unless defined(&w_retcode);
	eval 'sub w_stopval () { ($w_S->{w_Stopval});}' unless defined(&w_stopval);
	eval 'sub w_stopsig () { ($w_S->{w_Stopsig});}' unless defined(&w_stopsig);
	eval 'sub WSTOPPED () { &_WSTOPPED;}' unless defined(&WSTOPPED);
    }
    unless(defined(&_KERNEL)) {
	require 'sys/types.ph';
	require 'sys/cdefs.ph';
	unless(defined(&_POSIX_SOURCE)) {
	}
    }
}
1;
