[or-cvs] r13653: Patch from Sebastian Hahn: remove obsolete timeval manipulat (in tor/trunk: . src/common src/or)

nickm at seul.org nickm at seul.org
Thu Feb 21 14:33:20 UTC 2008


Author: nickm
Date: 2008-02-21 09:33:20 -0500 (Thu, 21 Feb 2008)
New Revision: 13653

Modified:
   tor/trunk/
   tor/trunk/src/common/util.c
   tor/trunk/src/common/util.h
   tor/trunk/src/or/test.c
Log:
 r18336 at catbus:  nickm | 2008-02-21 09:33:15 -0500
 Patch from Sebastian Hahn: remove obsolete timeval manipulation functions.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r18336] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/util.c
===================================================================
--- tor/trunk/src/common/util.c	2008-02-21 09:40:14 UTC (rev 13652)
+++ tor/trunk/src/common/util.c	2008-02-21 14:33:20 UTC (rev 13653)
@@ -969,43 +969,6 @@
   return udiff;
 }
 
-/** Return -1 if *a \< *b, 0 if *a==*b, and 1 if *a \> *b.
- */
-int
-tv_cmp(const struct timeval *a, const struct timeval *b)
-{
-  if (a->tv_sec > b->tv_sec)
-    return 1;
-  if (a->tv_sec < b->tv_sec)
-    return -1;
-  if (a->tv_usec > b->tv_usec)
-    return 1;
-  if (a->tv_usec < b->tv_usec)
-    return -1;
-  return 0;
-}
-
-/** Increment *a by the number of seconds and microseconds in *b.
- */
-void
-tv_add(struct timeval *a, const struct timeval *b)
-{
-  a->tv_usec += b->tv_usec;
-  a->tv_sec += b->tv_sec + (a->tv_usec / 1000000);
-  a->tv_usec %= 1000000;
-}
-
-/** Increment *a by <b>ms</b> milliseconds.
- */
-void
-tv_addms(struct timeval *a, long ms)
-{
-  uint64_t us = ms * 1000;
-  a->tv_usec += us % 1000000;
-  a->tv_sec += (us / 1000000) + (a->tv_usec / 1000000);
-  a->tv_usec %= 1000000;
-}
-
 /** Yield true iff <b>y</b> is a leap-year. */
 #define IS_LEAPYEAR(y) (!(y % 4) && ((y % 100) || !(y % 400)))
 /** Helper: Return the number of leap-days between Jan 1, y1 and Jan 1, y2. */

Modified: tor/trunk/src/common/util.h
===================================================================
--- tor/trunk/src/common/util.h	2008-02-21 09:40:14 UTC (rev 13652)
+++ tor/trunk/src/common/util.h	2008-02-21 14:33:20 UTC (rev 13653)
@@ -193,9 +193,6 @@
 
 /* Time helpers */
 long tv_udiff(const struct timeval *start, const struct timeval *end);
-void tv_addms(struct timeval *a, long ms);
-void tv_add(struct timeval *a, const struct timeval *b);
-int tv_cmp(const struct timeval *a, const struct timeval *b);
 time_t tor_timegm(struct tm *tm);
 #define RFC1123_TIME_LEN 29
 void format_rfc1123_time(char *buf, time_t t);

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2008-02-21 09:40:14 UTC (rev 13652)
+++ tor/trunk/src/or/test.c	2008-02-21 14:33:20 UTC (rev 13653)
@@ -723,10 +723,6 @@
 
   end.tv_usec = 7000;
 
-  test_assert(tv_cmp(&start, &end)<0);
-  test_assert(tv_cmp(&end, &start)>0);
-  test_assert(tv_cmp(&end, &end)==0);
-
   test_eq(2000L, tv_udiff(&start, &end));
 
   end.tv_sec = 6;
@@ -741,16 +737,9 @@
 
   test_eq(-1005000L, tv_udiff(&start, &end));
 
-  tv_addms(&end, 5090);
-  test_eq(end.tv_sec, 9);
-  test_eq(end.tv_usec, 90000);
-
   end.tv_usec = 999990;
   start.tv_sec = 1;
   start.tv_usec = 500;
-  tv_add(&start, &end);
-  test_eq(start.tv_sec, 11);
-  test_eq(start.tv_usec, 490);
 
   /* The test values here are confirmed to be correct on a platform
    * with a working timegm. */



More information about the tor-commits mailing list