]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
provide these functions as curlx_* ones as this enables the curl app to
authorDaniel Stenberg <daniel@haxx.se>
Tue, 6 Apr 2004 10:15:10 +0000 (10:15 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 6 Apr 2004 10:15:10 +0000 (10:15 +0000)
re-use these sources and functions for subsecond resolution timing

lib/timeval.c
lib/timeval.h

index b9bd1f994d683e1833f2cd0c80456e4a0040760b..20ac6ea96af40930e9f5aba1999fc2438eace570 100644 (file)
@@ -79,7 +79,7 @@ static int gettimeofday(struct timeval *tp, void *nothing)
 #endif /* HAVE_GETTIMEOFDAY */
 
 /* Return the current time in a timeval struct */
-struct timeval Curl_tvnow(void)
+struct timeval curlx_tvnow(void)
 {
   struct timeval now;
   (void)gettimeofday(&now, NULL);
@@ -92,10 +92,10 @@ struct timeval Curl_tvnow(void)
  *
  * Returns: the time difference in number of milliseconds.
  */
-long Curl_tvdiff(struct timeval newer, struct timeval older)
+long curlx_tvdiff(struct timeval newer, struct timeval older)
 {
   return (newer.tv_sec-older.tv_sec)*1000+
-    (499+newer.tv_usec-older.tv_usec)/1000;
+    (newer.tv_usec-older.tv_usec)/1000;
 }
 
 /* return the number of seconds in the given input timeval struct */
index cb984c8a6c312c30d004b0860936bdc4d880a71b..39da52a6fca38b8d821866ac460830ddf450372a 100644 (file)
  * $Id$
  ***************************************************************************/
 
+/*
+ * CAUTION: this header is designed to work when included by the app-side
+ * as well as the library. Do not mix with library internals!
+ */
+
 #include "setup.h"
 
 #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
@@ -40,10 +45,20 @@ struct timeval {
 #endif
 #endif
 
-struct timeval Curl_tvnow(void);
+struct timeval curlx_tvnow(void);
 
-/* the diff is from now on returned in number of milliseconds! */
-long Curl_tvdiff(struct timeval t1, struct timeval t2);
+/*
+ * Make sure that the first argument (t1) is the more recent time and t2 is
+ * the older time, as otherwise you get a weird negative time-diff back...
+ *
+ * Returns: the time difference in number of milliseconds.
+ */
+long curlx_tvdiff(struct timeval t1, struct timeval t2);
 long Curl_tvlong(struct timeval t1);
 
+/* These two defines below exist to provide the older API for library
+   internals only. */
+#define Curl_tvnow() curlx_tvnow()
+#define Curl_tvdiff(x,y) curlx_tvdiff(x,y)
+
 #endif