FreeBSD/contrib/ntp/ntpd/ntp_leapsec.c
/* [internal] fetch the leap era for a given time stamp.
 * This is a cut-down version the algorithm used to reload the table
 * limits, but it does not update any global state and provides just the
 * era information for a given time stamp.
 */
[internal] fetch the leap era for a given time stamp.
This is a cut-down version the algorithm used to reload the table
limits, but it does not update any global state and provides just the
era information for a given time stamp.
[ internal ] fetch the leap era for a given time stamp . This is a cut - down version the algorithm used to reload the table limits but it does not update any global state and provides just the era information for a given time stamp .
static void
fetch_leap_era(
	leap_era_t         * into,
	const leap_table_t * pt  ,
	const vint64       * ts  )
{
	int idx;
	for (idx = 0; idx != pt->head.size; idx++)
		if (ucmpv64(ts, &pt->info[idx].ttime) >= 0)
			break;
	if (idx >= pt->head.size) {
		memset(&into->ebase, 0x00, sizeof(vint64));
		into->taiof = pt->head.base_tai;
	} else {
		into->ebase = pt->info[idx].ttime;
		into->taiof = pt->info[idx].taiof;
	}
	if (--idx >= 0)
		into->ttime = pt->info[idx].ttime;
	else
		memset(&into->ttime, 0xFF, sizeof(vint64));
}
static void fetch_leap_era ( leap_era_t * into , const leap_table_t * pt , const vint64 * ts ) { int idx ; for ( idx = 0 ; idx != pt -> head . size ; idx ++ ) if ( ucmpv64 ( ts , & pt -> info [ idx ] . ttime ) >= 0 ) break ; if ( idx >= pt -> head . size ) { memset ( & into -> ebase , 0x00 , sizeof ( vint64 ) ) ; into -> taiof = pt -> head . base_tai ; } else { into -> ebase = pt -> info [ idx ] . ttime ; into -> taiof = pt -> info [ idx ] . taiof ; } if ( -- idx >= 0 ) into -> ttime = pt -> info [ idx ] . ttime ; else memset ( & into -> ttime , 0xFF , sizeof ( vint64 ) ) ; }
[internal] fetch the leap era for a given time stamp.
[ internal ] fetch the leap era for a given time stamp .
/* Simple search loop, also works with empty table. */ /* fetch era data, keeping an eye on boundary conditions */