FreeBSD/contrib/ntp/libntp/ntp_calendar.c
/*
 *---------------------------------------------------------------------
 * Split a 32bit seconds value into h/m/s and excessive days.  This
 * function happily accepts negative time values as timestamps before
 * midnight.
 *---------------------------------------------------------------------
 */
Split a 32bit seconds value into h/m/s and excessive days.  This
function happily accepts negative time values as timestamps before
midnight.
Split a 32bit seconds value into h / m / s and excessive days . This function happily accepts negative time values as timestamps before midnight .
static int32_t
priv_timesplit(
	int32_t split[3],
	int32_t ts
	)
{
	uint32_t us, um, uh, ud, sflag;
	sflag = int32_sflag(ts);
	us    = int32_to_uint32_2cpl(ts);
	um = (sflag ^ us) / SECSPERMIN;
	uh = um / MINSPERHR;
	ud = uh / HRSPERDAY;
	um ^= sflag;
	uh ^= sflag;
	ud ^= sflag;
	split[0] = (int32_t)(uh - ud * HRSPERDAY );
	split[1] = (int32_t)(um - uh * MINSPERHR );
	split[2] = (int32_t)(us - um * SECSPERMIN);
	return uint32_2cpl_to_int32(ud);
}
static int32_t priv_timesplit ( int32_t split [ 3 ] , int32_t ts ) { uint32_t us , um , uh , ud , sflag ; sflag = int32_sflag ( ts ) ; us = int32_to_uint32_2cpl ( ts ) ; um = ( sflag ^ us ) / SECSPERMIN ; uh = um / MINSPERHR ; ud = uh / HRSPERDAY ; um ^= sflag ; uh ^= sflag ; ud ^= sflag ; split [ 0 ] = ( int32_t ) ( uh - ud * HRSPERDAY ) ; split [ 1 ] = ( int32_t ) ( um - uh * MINSPERHR ) ; split [ 2 ] = ( int32_t ) ( us - um * SECSPERMIN ) ; return uint32_2cpl_to_int32 ( ud ) ; }
Split a 32bit seconds value into h/m/s and excessive days.
Split a 32bit seconds value into h / m / s and excessive days .
/* Do 3 chained floor divisions by positive constants, using the
	 * one's complement trick and factoring out the intermediate XOR
	 * ops to reduce the number of operations.
	 */