use the list for holding all the managed screens in the display. limit the number...
[dana/dcompmgr.git] / time.c
diff --git a/time.c b/time.c
index 38b60b2..a90b1cd 100644 (file)
--- a/time.c
+++ b/time.c
@@ -1,9 +1,8 @@
 #include "time.h"
 
-void
-time_add(struct timeval *tv, long microseconds)
+static inline void
+time_fix(struct timeval *tv)
 {
-    tv->tv_usec += microseconds;
     while (tv->tv_usec >= 1000000) {
         tv->tv_usec -= 1000000;
         ++tv->tv_sec;
@@ -14,6 +13,13 @@ time_add(struct timeval *tv, long microseconds)
     }
 }
 
+void
+time_add(struct timeval *tv, long microseconds)
+{
+    tv->tv_usec += microseconds;
+    time_fix(tv);
+}
+
 long
 time_compare(struct timeval *a, struct timeval *b)
 {
@@ -21,3 +27,13 @@ time_compare(struct timeval *a, struct timeval *b)
     if ((r = a->tv_sec - b->tv_sec)) return r;
     return a->tv_usec - b->tv_usec;
 }
+
+void
+time_difference(struct timeval *a, struct timeval *b, struct timeval *r)
+{
+    struct timeval v;
+    v.tv_sec = a->tv_sec - b->tv_sec;
+    v.tv_usec = a->tv_usec - b->tv_usec;
+    time_fix(&v);
+    *r = v;
+}