Add helper to easily determine how much time has passed since some previous
event.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4783 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx
index 265114f..2709f2c 100644
--- a/common/rfb/util.cxx
+++ b/common/rfb/util.cxx
@@ -34,6 +34,8 @@
 #include <config.h>
 #endif
 
+#include <sys/time.h>
+
 #include <rfb/util.h>
 
 // Provide strcasecmp() and/or strncasecmp() if absent on this system.
@@ -185,4 +187,18 @@
     dest[src ? destlen-1 : 0] = 0;
   }
 
+  unsigned msSince(const struct timeval *then)
+  {
+    struct timeval now;
+    unsigned diff;
+
+    gettimeofday(&now, NULL);
+
+    diff = (now.tv_sec - then->tv_sec) * 1000;
+
+    diff += now.tv_usec / 1000;
+    diff -= then->tv_usec / 1000;
+
+    return diff;
+  }
 };