Author: cperciva Date: Sun Nov 28 18:59:52 2010 New Revision: 216015 URL: http://svn.freebsd.org/changeset/base/216015
Log: MFC r215665,r215732: Don't lose seconds to integer overflow if we go more than one second between calls to tc_windup. Modified: stable/8/sys/kern/kern_tc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_tc.c ============================================================================== --- stable/8/sys/kern/kern_tc.c Sun Nov 28 18:53:57 2010 (r216014) +++ stable/8/sys/kern/kern_tc.c Sun Nov 28 18:59:52 2010 (r216015) @@ -440,6 +440,16 @@ tc_windup(void) ncount = 0; th->th_offset_count += delta; th->th_offset_count &= th->th_counter->tc_counter_mask; + while (delta > th->th_counter->tc_frequency) { + /* Eat complete unadjusted seconds. */ + delta -= th->th_counter->tc_frequency; + th->th_offset.sec++; + } + if ((delta > th->th_counter->tc_frequency / 2) && + (th->th_scale * delta < ((uint64_t)1 << 63))) { + /* The product th_scale * delta just barely overflows. */ + th->th_offset.sec++; + } bintime_addx(&th->th_offset, th->th_scale * delta); /* _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"