require '_h2ph_pre.ph';

unless(defined(&_SYS_TIME_H_)) {
    eval 'sub _SYS_TIME_H_ () {1;}' unless defined(&_SYS_TIME_H_);
    require 'sys/types.ph';
    eval 'sub TIMEVAL_TO_TIMESPEC {
        local($tv, $ts) = @_;
	    eval q({ ($ts)-> &tv_sec = ($tv)-> &tv_sec; ($ts)-> &tv_nsec = ($tv)-> &tv_usec * 1000; });
    }' unless defined(&TIMEVAL_TO_TIMESPEC);
    eval 'sub TIMESPEC_TO_TIMEVAL {
        local($tv, $ts) = @_;
	    eval q({ ($tv)-> &tv_sec = ($ts)-> &tv_sec; ($tv)-> &tv_usec = ($ts)-> &tv_nsec / 1000; });
    }' unless defined(&TIMESPEC_TO_TIMEVAL);
    eval 'sub DST_NONE () {0;}' unless defined(&DST_NONE);
    eval 'sub DST_USA () {1;}' unless defined(&DST_USA);
    eval 'sub DST_AUST () {2;}' unless defined(&DST_AUST);
    eval 'sub DST_WET () {3;}' unless defined(&DST_WET);
    eval 'sub DST_MET () {4;}' unless defined(&DST_MET);
    eval 'sub DST_EET () {5;}' unless defined(&DST_EET);
    eval 'sub DST_CAN () {6;}' unless defined(&DST_CAN);
    eval 'sub timerclear {
        local($tvp) = @_;
	    eval q(($tvp)-> &tv_sec = ($tvp)-> &tv_usec = 0);
    }' unless defined(&timerclear);
    eval 'sub timerisset {
        local($tvp) = @_;
	    eval q((($tvp)-> &tv_sec || ($tvp)-> &tv_usec));
    }' unless defined(&timerisset);
    eval 'sub timercmp {
        local($tvp, $uvp, $cmp) = @_;
	    eval q(((($tvp)-> &tv_sec == ($uvp)-> &tv_sec) ? (($tvp)-> &tv_usec $cmp ($uvp)-> &tv_usec) : (($tvp)-> &tv_sec $cmp ($uvp)-> &tv_sec)));
    }' unless defined(&timercmp);
    eval 'sub timeradd {
        local($tvp, $uvp, $vvp) = @_;
	    eval q( &do { ($vvp)-> &tv_sec = ($tvp)-> &tv_sec + ($uvp)-> &tv_sec; ($vvp)-> &tv_usec = ($tvp)-> &tv_usec + ($uvp)-> &tv_usec;  &if (($vvp)-> &tv_usec >= 1000000) { ($vvp)-> &tv_sec++; ($vvp)-> &tv_usec -= 1000000; } }  &while (0));
    }' unless defined(&timeradd);
    eval 'sub timersub {
        local($tvp, $uvp, $vvp) = @_;
	    eval q( &do { ($vvp)-> &tv_sec = ($tvp)-> &tv_sec - ($uvp)-> &tv_sec; ($vvp)-> &tv_usec = ($tvp)-> &tv_usec - ($uvp)-> &tv_usec;  &if (($vvp)-> &tv_usec < 0) { ($vvp)-> &tv_sec--; ($vvp)-> &tv_usec += 1000000; } }  &while (0));
    }' unless defined(&timersub);
    eval 'sub timespecclear {
        local($tsp) = @_;
	    eval q(($tsp)-> &tv_sec = ($tsp)-> &tv_nsec = 0);
    }' unless defined(&timespecclear);
    eval 'sub timespecisset {
        local($tsp) = @_;
	    eval q((($tsp)-> &tv_sec || ($tsp)-> &tv_nsec));
    }' unless defined(&timespecisset);
    eval 'sub timespeccmp {
        local($tsp, $usp, $cmp) = @_;
	    eval q(((($tsp)-> &tv_sec == ($usp)-> &tv_sec) ? (($tsp)-> &tv_nsec $cmp ($usp)-> &tv_nsec) : (($tsp)-> &tv_sec $cmp ($usp)-> &tv_sec)));
    }' unless defined(&timespeccmp);
    eval 'sub timespecadd {
        local($tsp, $usp, $vsp) = @_;
	    eval q( &do { ($vsp)-> &tv_sec = ($tsp)-> &tv_sec + ($usp)-> &tv_sec; ($vsp)-> &tv_nsec = ($tsp)-> &tv_nsec + ($usp)-> &tv_nsec;  &if (($vsp)-> &tv_nsec >= 1000000000) { ($vsp)-> &tv_sec++; ($vsp)-> &tv_nsec -= 1000000000; } }  &while (0));
    }' unless defined(&timespecadd);
    eval 'sub timespecsub {
        local($tsp, $usp, $vsp) = @_;
	    eval q( &do { ($vsp)-> &tv_sec = ($tsp)-> &tv_sec - ($usp)-> &tv_sec; ($vsp)-> &tv_nsec = ($tsp)-> &tv_nsec - ($usp)-> &tv_nsec;  &if (($vsp)-> &tv_nsec < 0) { ($vsp)-> &tv_sec--; ($vsp)-> &tv_nsec += 1000000000; } }  &while (0));
    }' unless defined(&timespecsub);
    eval 'sub ITIMER_REAL () {0;}' unless defined(&ITIMER_REAL);
    eval 'sub ITIMER_VIRTUAL () {1;}' unless defined(&ITIMER_VIRTUAL);
    eval 'sub ITIMER_PROF () {2;}' unless defined(&ITIMER_PROF);
    eval 'sub CLOCK_REALTIME () {0;}' unless defined(&CLOCK_REALTIME);
    eval 'sub CLOCK_VIRTUAL () {1;}' unless defined(&CLOCK_VIRTUAL);
    eval 'sub CLOCK_PROF () {2;}' unless defined(&CLOCK_PROF);
    eval 'sub TIMER_RELTIME () {0x0;}' unless defined(&TIMER_RELTIME);
    eval 'sub TIMER_ABSTIME () {0x1;}' unless defined(&TIMER_ABSTIME);
    if(defined( &_KERNEL) || defined( &_STANDALONE)) {
    } else {
	require 'time.ph';
	unless(defined(&_POSIX_SOURCE)) {
	    require 'sys/cdefs.ph';
	}
    }
}
1;
