require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_TIMEPPS_H_)) {
    eval 'sub _SYS_TIMEPPS_H_ () {1;}' unless defined(&_SYS_TIMEPPS_H_);
    require 'sys/ioccom.ph';
    eval 'sub PPS_API_VERS_1 () {1;}' unless defined(&PPS_API_VERS_1);
    eval 'sub assert_timestamp () { ($assert_tu->{tspec});}' unless defined(&assert_timestamp);
    eval 'sub clear_timestamp () { ($clear_tu->{tspec});}' unless defined(&clear_timestamp);
    eval 'sub assert_offset () { ($assert_off_tu->{tspec});}' unless defined(&assert_offset);
    eval 'sub clear_offset () { ($clear_off_tu->{tspec});}' unless defined(&clear_offset);
    eval 'sub PPS_CAPTUREASSERT () {0x1;}' unless defined(&PPS_CAPTUREASSERT);
    eval 'sub PPS_CAPTURECLEAR () {0x2;}' unless defined(&PPS_CAPTURECLEAR);
    eval 'sub PPS_CAPTUREBOTH () {0x3;}' unless defined(&PPS_CAPTUREBOTH);
    eval 'sub PPS_OFFSETASSERT () {0x10;}' unless defined(&PPS_OFFSETASSERT);
    eval 'sub PPS_OFFSETCLEAR () {0x20;}' unless defined(&PPS_OFFSETCLEAR);
    eval 'sub PPS_CANWAIT () {0x100;}' unless defined(&PPS_CANWAIT);
    eval 'sub PPS_CANPOLL () {0x200;}' unless defined(&PPS_CANPOLL);
    eval 'sub PPS_ECHOASSERT () {0x40;}' unless defined(&PPS_ECHOASSERT);
    eval 'sub PPS_ECHOCLEAR () {0x80;}' unless defined(&PPS_ECHOCLEAR);
    eval 'sub PPS_TSFMT_TSPEC () {0x1000;}' unless defined(&PPS_TSFMT_TSPEC);
    eval 'sub PPS_TSFMT_NTPLFP () {0x2000;}' unless defined(&PPS_TSFMT_NTPLFP);
    eval 'sub PPS_KC_HARDPPS () {0;}' unless defined(&PPS_KC_HARDPPS);
    eval 'sub PPS_KC_HARDPPS_PLL () {1;}' unless defined(&PPS_KC_HARDPPS_PLL);
    eval 'sub PPS_KC_HARDPPS_FLL () {2;}' unless defined(&PPS_KC_HARDPPS_FLL);
    eval 'sub PPS_IOC_CREATE () { &_IO(ord(\'1\'), 1);}' unless defined(&PPS_IOC_CREATE);
    eval 'sub PPS_IOC_DESTROY () { &_IO(ord(\'1\'), 2);}' unless defined(&PPS_IOC_DESTROY);
    eval 'sub PPS_IOC_SETPARAMS () { &_IOW(ord(\'1\'), 3,  &pps_params_t);}' unless defined(&PPS_IOC_SETPARAMS);
    eval 'sub PPS_IOC_GETPARAMS () { &_IOR(ord(\'1\'), 4,  &pps_params_t);}' unless defined(&PPS_IOC_GETPARAMS);
    eval 'sub PPS_IOC_GETCAP () { &_IOR(ord(\'1\'), 5, \'int\');}' unless defined(&PPS_IOC_GETCAP);
    eval 'sub PPS_IOC_FETCH () { &_IOWR(ord(\'1\'), 6,  &pps_info_t);}' unless defined(&PPS_IOC_FETCH);
    eval 'sub PPS_IOC_KCBIND () { &_IOW(ord(\'1\'), 7, \'int\');}' unless defined(&PPS_IOC_KCBIND);
    if(defined(&_KERNEL)) {
	require 'sys/mutex.ph';
	eval 'sub PPS_REFEVNT_CAPTURE () {0x1;}' unless defined(&PPS_REFEVNT_CAPTURE);
	eval 'sub PPS_REFEVNT_CURRENT () {0x2;}' unless defined(&PPS_REFEVNT_CURRENT);
	eval 'sub PPS_REFEVNT_CAPCUR () {0x4;}' unless defined(&PPS_REFEVNT_CAPCUR);
	eval 'sub PPS_REFEVNT_RMASK () {0xf;}' unless defined(&PPS_REFEVNT_RMASK);
	eval 'sub PPS_REFEVNT_PPS () {0x10;}' unless defined(&PPS_REFEVNT_PPS);
    } else {
	require 'sys/cdefs.ph';
	require 'sys/ioctl.ph';
	require 'errno.ph';
    }
    eval 'sub time_pps_destroy {
        my($handle) = @_;
	    eval q({ (0); });
    }' unless defined(&time_pps_destroy);
    eval 'sub time_pps_setparams {
        my($handle,$ppsparams) = @_;
	    eval q({ ( &ioctl($handle,  &PPS_IOC_SETPARAMS,  &__UNCONST($ppsparams))); });
    }' unless defined(&time_pps_setparams);
    eval 'sub time_pps_getparams {
        my($handle,$ppsparams) = @_;
	    eval q({ ( &ioctl($handle,  &PPS_IOC_GETPARAMS, $ppsparams)); });
    }' unless defined(&time_pps_getparams);
    eval 'sub time_pps_getcap {
        my($handle,$mode) = @_;
	    eval q({ ( &ioctl($handle,  &PPS_IOC_GETCAP, $mode)); });
    }' unless defined(&time_pps_getcap);
    eval 'sub time_pps_fetch {
        my($handle,$tsformat,$ppsinfobuf,$timeout) = @_;
	    eval q({ ( &ioctl($handle,  &PPS_IOC_FETCH, $ppsinfobuf)); });
    }' unless defined(&time_pps_fetch);
    eval 'sub time_pps_kcbind {
        my($handle,$kernel_consumer,$edge,$tsformat) = @_;
	    eval q({  &if ($tsformat !=  &PPS_TSFMT_TSPEC) {  &errno =  &EINVAL; -1; } ( &ioctl($handle,  &PPS_IOC_KCBIND,  &__UNCONST($edge))); });
    }' unless defined(&time_pps_kcbind);
}
    }
1;
