svn commit: r237802 - projects/calloutng/sys/netinet

Davide Italiano davide at FreeBSD.org
Fri Jun 29 17:05:14 UTC 2012


Author: davide
Date: Fri Jun 29 17:05:13 2012
New Revision: 237802
URL: http://svn.freebsd.org/changeset/base/237802

Log:
  Introduce the delta_bintime_in_msecs() as suggested by Bruce Evans. While
  here, make an attempt to fix some style bugs.
  
  Reported by:		bde

Modified:
  projects/calloutng/sys/netinet/tcp_timer.c

Modified: projects/calloutng/sys/netinet/tcp_timer.c
==============================================================================
--- projects/calloutng/sys/netinet/tcp_timer.c	Fri Jun 29 17:04:42 2012	(r237801)
+++ projects/calloutng/sys/netinet/tcp_timer.c	Fri Jun 29 17:05:13 2012	(r237802)
@@ -662,52 +662,39 @@ tcp_timer_active(struct tcpcb *tp, int t
 
 #define	ticks_to_msecs(t)	(1000*(t) / hz)
 
-#define bintime_to_msecs(bt)						\
-	(((uint64_t)1000 *						\
-	(uint32_t)  (bt.frac >> 32)) >> 32) + (bt.sec * 1000); 
+static int
+delta_bintime_in_msecs(struct bintime bt, struct bintime now) 
+{
+	bintime_sub(&bt, &now);
+	return (((uint64_t) 1000 * (uint64_t) (bt.frac >> 32)) >> 32) +
+	    (bt.sec * 1000);
+}
 
 void
-tcp_timer_to_xtimer(struct tcpcb *tp, struct tcp_timer *timer, struct xtcp_timer *xtimer)
+tcp_timer_to_xtimer(struct tcpcb *tp, struct tcp_timer *timer, 
+    struct xtcp_timer *xtimer)
 {
-	struct bintime now;
-	struct bintime bt;
+	struct bintime bt, now;
 	
-	bzero(xtimer, sizeof(struct xtcp_timer));
+	bzero(xtimer, sizeof(xtimer));
 	if (timer == NULL)
 		return;
+	bintime_clear(&bt);
 	getbinuptime(&now);	
-	bt.sec = 0;
-	bt.frac = 0;
-
-	if (callout_active(&timer->tt_delack)) {
-		bt = timer->tt_delack.c_time;		
-		bintime_sub(&bt,&now);
-		xtimer->tt_delack = bintime_to_msecs(bt);
-	}
-	
-	if (callout_active(&timer->tt_rexmt)) {
-		bt = timer->tt_rexmt.c_time;
-		bintime_sub(&bt,&now);
-		xtimer->tt_rexmt = bintime_to_msecs(bt);
-	}
-	
-	if (callout_active(&timer->tt_persist)) {
-		bt = timer->tt_persist.c_time;
-		bintime_sub(&bt,&now);
-		xtimer->tt_persist = bintime_to_msecs(bt);
-	}
-	
-	if (callout_active(&timer->tt_keep)) {
-		bt = timer->tt_keep.c_time;
-		bintime_sub(&bt,&now); 
-		xtimer->tt_keep = bintime_to_msecs(bt);
-	}
-
-	if (callout_active(&timer->tt_2msl)) {
-		bt = timer->tt_2msl.c_time;
-		bintime_sub(&bt,&now);
-		xtimer->tt_2msl = bintime_to_msecs(bt);
-	}
-
+	if (callout_active(&timer->tt_delack)) 
+		xtimer->tt_delack = delta_bintime_in_msecs(
+		    timer->tt_delack.c_time, now);
+	if (callout_active(&timer->tt_rexmt)) 
+		xtimer->tt_rexmt = delta_bintime_in_msecs(
+		    timer->tt_rexmt.c_time, now);
+	if (callout_active(&timer->tt_persist)) 
+		xtimer->tt_persist = delta_bintime_in_msecs(
+		    timer->tt_persist.c_time, now);
+	if (callout_active(&timer->tt_keep)) 
+		xtimer->tt_keep = delta_bintime_in_msecs(
+		    timer->tt_keep.c_time, now);
+	if (callout_active(&timer->tt_2msl)) 
+		xtimer->tt_2msl = delta_bintime_in_msecs(
+		    timer->tt_2msl.c_time, now);
 	xtimer->t_rcvtime = ticks_to_msecs(ticks - tp->t_rcvtime);
 }


More information about the svn-src-projects mailing list