Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Apr 2014 23:29:29 +0000 (UTC)
From:      Davide Italiano <davide@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r264388 - in head/sys: kern sys
Message-ID:  <201404122329.s3CNTTSZ002375@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: davide
Date: Sat Apr 12 23:29:29 2014
New Revision: 264388
URL: http://svnweb.freebsd.org/changeset/base/264388

Log:
  Hide internal details of sbintime_t implementation wrapping INT64_MAX into
  SBT_MAX, to make it more robust in case internal type representation will
  change in the future. All the consumers were migrated to SBT_MAX and
  every new consumer (if any) should from now use this interface.
  
  Requested by:	bapt, jmg, Ryan Lortie (implictly)
  Reviewed by:	mav, bde

Modified:
  head/sys/kern/kern_clocksource.c
  head/sys/kern/kern_event.c
  head/sys/kern/kern_timeout.c
  head/sys/kern/sys_generic.c
  head/sys/sys/time.h

Modified: head/sys/kern/kern_clocksource.c
==============================================================================
--- head/sys/kern/kern_clocksource.c	Sat Apr 12 22:36:26 2014	(r264387)
+++ head/sys/kern/kern_clocksource.c	Sat Apr 12 23:29:29 2014	(r264388)
@@ -217,13 +217,13 @@ handleevents(sbintime_t now, int fake)
 	} else
 		state->nextprof = state->nextstat;
 	if (now >= state->nextcallopt) {
-		state->nextcall = state->nextcallopt = INT64_MAX;
+		state->nextcall = state->nextcallopt = SBT_MAX;
 		callout_process(now);
 	}
 
 #ifdef KDTRACE_HOOKS
 	if (fake == 0 && now >= state->nextcyc && cyclic_clock_func != NULL) {
-		state->nextcyc = INT64_MAX;
+		state->nextcyc = SBT_MAX;
 		(*cyclic_clock_func)(frame);
 	}
 #endif
@@ -509,7 +509,7 @@ configtimer(int start)
 			state = DPCPU_ID_PTR(cpu, timerstate);
 			state->now = now;
 			if (!smp_started && cpu != CPU_FIRST())
-				state->nextevent = INT64_MAX;
+				state->nextevent = SBT_MAX;
 			else
 				state->nextevent = next;
 			if (periodic)
@@ -598,10 +598,10 @@ cpu_initclocks_bsp(void)
 		state = DPCPU_ID_PTR(cpu, timerstate);
 		mtx_init(&state->et_hw_mtx, "et_hw_mtx", NULL, MTX_SPIN);
 #ifdef KDTRACE_HOOKS
-		state->nextcyc = INT64_MAX;
+		state->nextcyc = SBT_MAX;
 #endif
-		state->nextcall = INT64_MAX;
-		state->nextcallopt = INT64_MAX;
+		state->nextcall = SBT_MAX;
+		state->nextcallopt = SBT_MAX;
 	}
 	periodic = want_periodic;
 	/* Grab requested timer or the best of present. */

Modified: head/sys/kern/kern_event.c
==============================================================================
--- head/sys/kern/kern_event.c	Sat Apr 12 22:36:26 2014	(r264387)
+++ head/sys/kern/kern_event.c	Sat Apr 12 23:29:29 2014	(r264388)
@@ -528,8 +528,8 @@ timer2sbintime(intptr_t data)
 {
 
 #ifdef __LP64__
-	if (data > INT64_MAX / SBT_1MS)
-		return INT64_MAX;
+	if (data > SBT_MAX / SBT_1MS)
+		return (SBT_MAX);
 #endif
 	return (SBT_1MS * data);
 }
@@ -1399,7 +1399,7 @@ kqueue_scan(struct kqueue *kq, int maxev
 				rsbt = tstosbt(*tsp);
 				if (TIMESEL(&asbt, rsbt))
 					asbt += tc_tick_sbt;
-				if (asbt <= INT64_MAX - rsbt)
+				if (asbt <= SBT_MAX - rsbt)
 					asbt += rsbt;
 				else
 					asbt = 0;

Modified: head/sys/kern/kern_timeout.c
==============================================================================
--- head/sys/kern/kern_timeout.c	Sat Apr 12 22:36:26 2014	(r264387)
+++ head/sys/kern/kern_timeout.c	Sat Apr 12 23:29:29 2014	(r264388)
@@ -302,7 +302,7 @@ callout_cpu_init(struct callout_cpu *cc)
 	for (i = 0; i < callwheelsize; i++)
 		LIST_INIT(&cc->cc_callwheel[i]);
 	TAILQ_INIT(&cc->cc_expireq);
-	cc->cc_firstevent = INT64_MAX;
+	cc->cc_firstevent = SBT_MAX;
 	for (i = 0; i < 2; i++)
 		cc_cce_cleanup(cc, i);
 	if (cc->cc_callout == NULL)	/* Only cpu0 handles timeout(9) */
@@ -574,8 +574,8 @@ callout_cc_add(struct callout *c, struct
 	 * Inform the eventtimers(4) subsystem there's a new callout
 	 * that has been inserted, but only if really required.
 	 */
-	if (INT64_MAX - c->c_time < c->c_precision)
-		c->c_precision = INT64_MAX - c->c_time;
+	if (SBT_MAX - c->c_time < c->c_precision)
+		c->c_precision = SBT_MAX - c->c_time;
 	sbt = c->c_time + c->c_precision;
 	if (sbt < cc->cc_firstevent) {
 		cc->cc_firstevent = sbt;
@@ -953,8 +953,8 @@ callout_reset_sbt_on(struct callout *c, 
 				to_sbt += tick_sbt;
 		} else
 			to_sbt = sbinuptime();
-		if (INT64_MAX - to_sbt < sbt)
-			to_sbt = INT64_MAX;
+		if (SBT_MAX - to_sbt < sbt)
+			to_sbt = SBT_MAX;
 		else
 			to_sbt += sbt;
 		pr = ((C_PRELGET(flags) < 0) ? sbt >> tc_precexp :

Modified: head/sys/kern/sys_generic.c
==============================================================================
--- head/sys/kern/sys_generic.c	Sat Apr 12 22:36:26 2014	(r264387)
+++ head/sys/kern/sys_generic.c	Sat Apr 12 23:29:29 2014	(r264388)
@@ -1072,7 +1072,7 @@ kern_select(struct thread *td, int nd, f
 			precision >>= tc_precexp;
 			if (TIMESEL(&asbt, rsbt))
 				asbt += tc_tick_sbt;
-			if (asbt <= INT64_MAX - rsbt)
+			if (asbt <= SBT_MAX - rsbt)
 				asbt += rsbt;
 			else
 				asbt = -1;
@@ -1547,7 +1547,7 @@ selsocket(struct socket *so, int events,
 			precision >>= tc_precexp;
 			if (TIMESEL(&asbt, rsbt))
 				asbt += tc_tick_sbt;
-			if (asbt <= INT64_MAX - rsbt)
+			if (asbt <= SBT_MAX - rsbt)
 				asbt += rsbt;
 			else
 				asbt = -1;

Modified: head/sys/sys/time.h
==============================================================================
--- head/sys/sys/time.h	Sat Apr 12 22:36:26 2014	(r264387)
+++ head/sys/sys/time.h	Sat Apr 12 23:29:29 2014	(r264388)
@@ -129,6 +129,7 @@ bintime_shift(struct bintime *_bt, int _
 #define	SBT_1MS	(SBT_1S / 1000)
 #define	SBT_1US	(SBT_1S / 1000000)
 #define	SBT_1NS	(SBT_1S / 1000000000)
+#define	SBT_MAX	INT64_MAX
 
 static __inline int
 sbintime_getsec(sbintime_t _sbt)



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