[Asterisk-cvs] asterisk/include/asterisk time.h,1.6,1.7

kpfleming at lists.digium.com kpfleming at lists.digium.com
Tue Jul 19 19:20:54 CDT 2005


Update of /usr/cvsroot/asterisk/include/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv19463/include/asterisk

Modified Files:
	time.h 
Log Message:
restore proper difference calculation (bug #4746)


Index: time.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/time.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- time.h	19 Jul 2005 19:06:24 -0000	1.6
+++ time.h	19 Jul 2005 23:28:12 -0000	1.7
@@ -32,7 +32,13 @@
 AST_INLINE_API(
 int ast_tvdiff_ms(struct timeval end, struct timeval start),
 {
-	return ((end.tv_sec - start.tv_sec) * 1000) + ((end.tv_usec - start.tv_usec) / 1000);
+	/* the offset by 1,000,000 below is intentional...
+	   it avoids differences in the way that division
+	   is handled for positive and negative numbers, by ensuring
+	   that the divisor is always positive
+	*/
+	return  ((end.tv_sec - start.tv_sec) * 1000) +
+		(((1000000 + end.tv_usec - start.tv_usec) / 1000) - 1000);
 }
 )
 




More information about the svn-commits mailing list