FreeBSD/contrib/ntp/ntpdate/ntpdate.c
/*
 * adj_systime - do a big long slew of the system time
 */
do a big long slew of the system time
do a big long slew of the system time
static int
l_adj_systime(
	l_fp *ts
	)
{
	struct timeval adjtv, oadjtv;
	int isneg = 0;
	l_fp offset;
#ifndef STEP_SLEW
	l_fp overshoot;
#endif
	offset = *ts;
	if (L_ISNEG(&offset)) {
		isneg = 1;
		L_NEG(&offset);
	}
#ifndef STEP_SLEW
	overshoot = offset;
	L_RSHIFTU(&overshoot);
	if (overshoot.l_ui != 0 || (overshoot.l_uf > ADJ_MAXOVERSHOOT)) {
		overshoot.l_ui = 0;
		overshoot.l_uf = ADJ_MAXOVERSHOOT;
	}
	L_ADD(&offset, &overshoot);
#endif
	TSTOTV(&offset, &adjtv);
	if (isneg) {
		adjtv.tv_sec = -adjtv.tv_sec;
		adjtv.tv_usec = -adjtv.tv_usec;
	}
	if (adjtv.tv_usec != 0 && !debug) {
		if (adjtime(&adjtv, &oadjtv) < 0) {
			msyslog(LOG_ERR, "Can't adjust the time of day: %m");
			exit(1);
		}
	}
	return 1;
}
static int l_adj_systime ( l_fp * ts ) { struct timeval adjtv , oadjtv ; int isneg = 0 ; l_fp offset ; #ifndef STEP_SLEW l_fp overshoot ; #endif offset = * ts ; if ( L_ISNEG ( & offset ) ) { isneg = 1 ; L_NEG ( & offset ) ; } #ifndef STEP_SLEW overshoot = offset ; L_RSHIFTU ( & overshoot ) ; if ( overshoot . l_ui != 0 || ( overshoot . l_uf > ADJ_MAXOVERSHOOT ) ) { overshoot . l_ui = 0 ; overshoot . l_uf = ADJ_MAXOVERSHOOT ; } L_ADD ( & offset , & overshoot ) ; #endif TSTOTV ( & offset , & adjtv ) ; if ( isneg ) { adjtv . tv_sec = - adjtv . tv_sec ; adjtv . tv_usec = - adjtv . tv_usec ; } if ( adjtv . tv_usec != 0 && ! debug ) { if ( adjtime ( & adjtv , & oadjtv ) < 0 ) { msyslog ( LOG_ERR , " " ) ; exit ( 1 ) ; } } return 1 ; }
adj_systime - do a big long slew of the system time
adj_systime - do a big long slew of the system time
/*
	 * Take the absolute value of the offset
	 */ /*
	 * Calculate the overshoot.  XXX N.B. This code *knows*
	 * ADJ_OVERSHOOT is 1/2.
	 */