require '_h2ph_pre.ph';

unless(defined(&_SYS_TIMEX_H_)) {
    eval 'sub _SYS_TIMEX_H_ () {1;}' unless defined(&_SYS_TIMEX_H_);
    unless(defined(&MSDOS)) {
	require 'sys/syscall.ph';
    }
    eval 'sub SHIFT_KG () {6;}' unless defined(&SHIFT_KG);
    eval 'sub SHIFT_KF () {16;}' unless defined(&SHIFT_KF);
    eval 'sub SHIFT_KH () {2;}' unless defined(&SHIFT_KH);
    eval 'sub MAXTC () {6;}' unless defined(&MAXTC);
    eval 'sub SHIFT_SCALE () {22;}' unless defined(&SHIFT_SCALE);
    eval 'sub SHIFT_UPDATE () {( &SHIFT_KG +  &MAXTC);}' unless defined(&SHIFT_UPDATE);
    eval 'sub SHIFT_USEC () {16;}' unless defined(&SHIFT_USEC);
    eval 'sub FINEUSEC () {(1 <<  &SHIFT_SCALE);}' unless defined(&FINEUSEC);
    eval 'sub MAXPHASE () {512000;}' unless defined(&MAXPHASE);
    if(defined(&PPS_SYNC)) {
	eval 'sub MAXFREQ () {(512 <<  &SHIFT_USEC);}' unless defined(&MAXFREQ);
	eval 'sub MAXTIME () {(200 <<  &PPS_AVG);}' unless defined(&MAXTIME);
    } else {
	eval 'sub MAXFREQ () {(512 <<  &SHIFT_USEC);}' unless defined(&MAXFREQ);
    }
    eval 'sub MINSEC () {16;}' unless defined(&MINSEC);
    eval 'sub MAXSEC () {1200;}' unless defined(&MAXSEC);
    if(defined(&PPS_SYNC)) {
	eval 'sub PPS_AVG () {2;}' unless defined(&PPS_AVG);
	eval 'sub PPS_SHIFT () {2;}' unless defined(&PPS_SHIFT);
	eval 'sub PPS_SHIFTMAX () {8;}' unless defined(&PPS_SHIFTMAX);
	eval 'sub PPS_VALID () {120;}' unless defined(&PPS_VALID);
	eval 'sub MAXGLITCH () {30;}' unless defined(&MAXGLITCH);
    }
    eval 'sub MOD_OFFSET () {0x0001;}' unless defined(&MOD_OFFSET);
    eval 'sub MOD_FREQUENCY () {0x0002;}' unless defined(&MOD_FREQUENCY);
    eval 'sub MOD_MAXERROR () {0x0004;}' unless defined(&MOD_MAXERROR);
    eval 'sub MOD_ESTERROR () {0x0008;}' unless defined(&MOD_ESTERROR);
    eval 'sub MOD_STATUS () {0x0010;}' unless defined(&MOD_STATUS);
    eval 'sub MOD_TIMECONST () {0x0020;}' unless defined(&MOD_TIMECONST);
    eval 'sub MOD_CLKB () {0x4000;}' unless defined(&MOD_CLKB);
    eval 'sub MOD_CLKA () {0x8000;}' unless defined(&MOD_CLKA);
    eval 'sub STA_PLL () {0x0001;}' unless defined(&STA_PLL);
    eval 'sub STA_PPSFREQ () {0x0002;}' unless defined(&STA_PPSFREQ);
    eval 'sub STA_PPSTIME () {0x0004;}' unless defined(&STA_PPSTIME);
    eval 'sub STA_FLL () {0x0008;}' unless defined(&STA_FLL);
    eval 'sub STA_INS () {0x0010;}' unless defined(&STA_INS);
    eval 'sub STA_DEL () {0x0020;}' unless defined(&STA_DEL);
    eval 'sub STA_UNSYNC () {0x0040;}' unless defined(&STA_UNSYNC);
    eval 'sub STA_FREQHOLD () {0x0080;}' unless defined(&STA_FREQHOLD);
    eval 'sub STA_PPSSIGNAL () {0x0100;}' unless defined(&STA_PPSSIGNAL);
    eval 'sub STA_PPSJITTER () {0x0200;}' unless defined(&STA_PPSJITTER);
    eval 'sub STA_PPSWANDER () {0x0400;}' unless defined(&STA_PPSWANDER);
    eval 'sub STA_PPSERROR () {0x0800;}' unless defined(&STA_PPSERROR);
    eval 'sub STA_CLOCKERR () {0x1000;}' unless defined(&STA_CLOCKERR);
    eval 'sub STA_RONLY () {( &STA_PPSSIGNAL |  &STA_PPSJITTER |  &STA_PPSWANDER |  &STA_PPSERROR |  &STA_CLOCKERR);}' unless defined(&STA_RONLY);
    eval 'sub TIME_OK () {0;}' unless defined(&TIME_OK);
    eval 'sub TIME_INS () {1;}' unless defined(&TIME_INS);
    eval 'sub TIME_DEL () {2;}' unless defined(&TIME_DEL);
    eval 'sub TIME_OOP () {3;}' unless defined(&TIME_OOP);
    eval 'sub TIME_WAIT () {4;}' unless defined(&TIME_WAIT);
    eval 'sub TIME_ERROR () {5;}' unless defined(&TIME_ERROR);
    if(defined( &__FreeBSD__) || defined( &__NetBSD__) || defined( &__OpenBSD__)) {
	unless(defined(&_KERNEL)) {
	    require 'sys/cdefs.ph';
	}
    }
}
1;
