Lines Matching +full:tv +full:- +full:set
3 * Copyright (c) David L. Mills 1999-2000 *
19 * This header file complies with "Pulse-Per-Second API for UNIX-like *
37 * based on code by Poul-Henning Kamp <phk@FreeBSD.org> *
41 * "THE BEER-WARE LICENSE" (Revision 42): *
45 * in return. Poul-Henning Kamp *
58 * means the bit is set.
66 #define PPS_JAN_1970 2208988800UL /* 1970 - 1900 in seconds */
73 (x).tv_nsec -= PPS_NANOSECOND; \
77 (x).tv_sec--; \
126 #define PPS_KC_HARDPPS_PLL 1 /* phase-lock mode */
127 #define PPS_KC_HARDPPS_FLL 2 /* frequency-lock mode */
138 } ntp_fp_t; /* NTP-compatible time stamp */
182 * The following definitions are architecture-dependent
190 pps_params_t params; /* PPS parameters set by user */
198 *------ Here begins the implementation-specific part! ------
221 return (-1); /* null pointer */ in time_pps_create()
231 return (-1); /* what, no memory? */ in time_pps_create()
235 (*handle)->filedes = filedes; in time_pps_create()
236 (*handle)->params.api_version = PPS_API_VERS_1; in time_pps_create()
237 (*handle)->params.mode = PPS_CAPTUREASSERT | PPS_TSFMT_TSPEC; in time_pps_create()
256 return (-1); /* bad handle */ in time_pps_destroy()
263 * set parameters for handle
274 * Check for valid arguments and set parameters. in time_pps_setparams()
279 return (-1); /* bad handle */ in time_pps_setparams()
284 return (-1); /* bad argument */ in time_pps_setparams()
289 * I require `api_version' to be set! in time_pps_setparams()
292 if (params->api_version != PPS_API_VERS_1) { in time_pps_setparams()
294 return(-1); in time_pps_setparams()
301 mode_in = params->mode; in time_pps_setparams()
303 /* turn off read-only bits */ in time_pps_setparams()
311 return(-1); in time_pps_setparams()
318 mode = handle->params.mode; in time_pps_setparams()
319 memcpy(&handle->params, params, sizeof(pps_params_t)); in time_pps_setparams()
320 handle->params.api_version = PPS_API_VERS_1; in time_pps_setparams()
321 handle->params.mode = mode | mode_in; in time_pps_setparams()
341 return (-1); /* bad handle */ in time_pps_getparams()
346 return (-1); /* bad argument */ in time_pps_getparams()
349 memcpy(params, &handle->params, sizeof(pps_params_t)); in time_pps_getparams()
369 return (-1); /* bad handle */ in time_pps_getcap()
374 return (-1); /* bad argument */ in time_pps_getcap()
392 struct timeval tv; in time_pps_fetch() local
401 return (-1); /* bad handle */ in time_pps_fetch()
406 return (-1); /* bad argument */ in time_pps_fetch()
410 * nb. PPS_CANWAIT is NOT set by the implementation, we can totally in time_pps_fetch()
420 if (!handle->params.mode & PPS_CAPTUREASSERT) { in time_pps_fetch()
425 if (ioctl(instance->filedes, TIOCDCDTIMESTAMP, &tv) < 0) { in time_pps_fetch()
428 return(-1); in time_pps_fetch()
435 if (tv.tv_sec != handle->tv_save.tv_sec || tv.tv_usec != handle->tv_save.tv_usec) { in time_pps_fetch()
436 handle->tv_save = tv; in time_pps_fetch()
437 handle->serial++; in time_pps_fetch()
445 infobuf.assert_sequence = handle->serial; in time_pps_fetch()
446 infobuf.assert_timestamp.tv_sec = tv.tv_sec; in time_pps_fetch()
447 infobuf.assert_timestamp.tv_nsec = tv.tv_usec * 1000; in time_pps_fetch()
449 if (handle->params.mode & PPS_OFFSETASSERT) { in time_pps_fetch()
450 infobuf.assert_timestamp.tv_sec += handle->params.assert_offset.tv_sec; in time_pps_fetch()
451 infobuf.assert_timestamp.tv_nsec += handle->params.assert_offset.tv_nsec; in time_pps_fetch()
469 return (-1); in time_pps_fetch()
472 infobuf.current_mode = handle->params.mode; in time_pps_fetch()
493 return (-1); /* bad handle */ in time_pps_kcbind()
497 return (-1); /* must be superuser */ in time_pps_kcbind()
500 return(-1); in time_pps_kcbind()