Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jul 2017 00:45:22 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321002 - head/sys/kern
Message-ID:  <201707150045.v6F0jMoC069952@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sat Jul 15 00:45:22 2017
New Revision: 321002
URL: https://svnweb.freebsd.org/changeset/base/321002

Log:
  Revert r320997.  There are reports of it getting the wrong results, so
  clearly my testing was insuffficent, and it's best to just revert it
  until I get it straightened out.

Modified:
  head/sys/kern/subr_clock.c

Modified: head/sys/kern/subr_clock.c
==============================================================================
--- head/sys/kern/subr_clock.c	Fri Jul 14 21:50:04 2017	(r321001)
+++ head/sys/kern/subr_clock.c	Sat Jul 15 00:45:22 2017	(r321002)
@@ -97,13 +97,6 @@ static const int month_days[12] = {
 	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
 };
 
-/*
- * Optimization: using a precomputed count of days between POSIX_BASE_YEAR and a
- * recent year avoids lots of needless loop iterations in conversion.
- * recent_base_days is the number of days through the end of recent_base_year.
- */
-static const int recent_base_year = 2016;
-static const int recent_base_days = 17167;
 
 /*
  * This inline avoids some unnecessary modulo operations
@@ -164,14 +157,8 @@ clock_ct_to_ts(struct clocktime *ct, struct timespec *
 	 * Compute days since start of time
 	 * First from years, then from months.
 	 */
-	if (year > recent_base_year) {
-		i = recent_base_year;
-		days = recent_base_days;
-	} else {
-		i = POSIX_BASE_YEAR;
-		days = 0;
-	}
-	for (; i < year; i++)
+	days = 0;
+	for (i = POSIX_BASE_YEAR; i < year; i++)
 		days += days_in_year(i);
 
 	/* Months */
@@ -201,14 +188,8 @@ clock_ts_to_ct(struct timespec *ts, struct clocktime *
 
 	ct->dow = day_of_week(days);
 
-	/* Subtract out whole years. */
-	if (days >= recent_base_days) {
-		year = recent_base_year + 1;
-		days -= recent_base_days;
-	} else {
-		year = POSIX_BASE_YEAR;
-	}
-	for (; days >= days_in_year(year); year++)
+	/* Subtract out whole years, counting them in i. */
+	for (year = POSIX_BASE_YEAR; days >= days_in_year(year); year++)
 		days -= days_in_year(year);
 	ct->year = year;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707150045.v6F0jMoC069952>