Merge "Add timespec/timeval conversion helpers."
diff --git a/libc/include/sys/time.h b/libc/include/sys/time.h
index 1f010d4..67107c6 100644
--- a/libc/include/sys/time.h
+++ b/libc/include/sys/time.h
@@ -73,6 +73,15 @@
} \
} while (0)
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+
__END_DECLS
#endif /* _SYS_TIME_H_ */