- define timeradd if sys/time.h doesn't define it

Piotr Pawlow [2014-03-13 20:49:48]
- define timeradd if sys/time.h doesn't define it
Filename
src/lingot-core.c
diff --git a/src/lingot-core.c b/src/lingot-core.c
index a7554a6..0d5c31f 100644
--- a/src/lingot-core.c
+++ b/src/lingot-core.c
@@ -38,6 +38,19 @@
 #include "lingot-i18n.h"
 #include "lingot-msg.h"

+#ifndef timeradd
+#define timeradd(a, b, result)                                               \
+  do {                                                                        \
+    (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;                             \
+    (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;                          \
+    if ((result)->tv_usec >= 1000000)                                         \
+      {                                                                       \
+        ++(result)->tv_sec;                                                   \
+        (result)->tv_usec -= 1000000;                                         \
+      }                                                                       \
+  } while (0)
+#endif
+
 int
 lingot_core_read_callback(FLT* read_buffer, int read_buffer_size, void *arg);
ViewGit