summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/sys_time.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/utils/sys_time.h b/utils/sys_time.h
index 82d88fd25..fe8e5f6f3 100644
--- a/utils/sys_time.h
+++ b/utils/sys_time.h
@@ -18,14 +18,26 @@
/**
* \file
- * \brief BSD style time functions
+ * BSD style timeval macros
+ *
+ * BSD added macros for manipulating timeval which have become standard on
+ * modern c libraries but for compatability where they are missing it is
+ * necessary to provide fallbacks.
*/
-#ifndef _NETSURF_UTILS_SYS_TIME_H_
-#define _NETSURF_UTILS_SYS_TIME_H_
+#ifndef NETSURF_UTILS_SYS_TIME_H_
+#define NETSURF_UTILS_SYS_TIME_H_
#include <sys/time.h>
+#ifndef timerclear
+#define timerclear(a) (a)->tv_sec = (a)->tv_usec = 0
+#endif
+
+#ifndef timerisset
+#define timerisset(a) ((a)->tv_sec || (a)->tv_usec)
+#endif
+
#ifndef timeradd
#define timeradd(a, aa, result) \
do { \
@@ -50,4 +62,10 @@
} while (0)
#endif
+#ifndef timercmp
+#define timercmp(a, aa, cmp) \
+ ((a)->tv_sec cmp (aa)->tv_sec || \
+ (a)->tv_sec == (aa)->tv_sec && (a)->tv_usec cmp (aa)->tv_usec)
+#endif
+
#endif