Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
extern time_t timegm(struct tm *tm);
#endif
+static inline usec_t timeval_to_usec(const struct timeval *t)
+{
+ return t->tv_sec * USEC_PER_SEC + t->tv_usec;
+}
+
+static inline usec_t timespec_to_usec(const struct timespec *t)
+{
+ return t->tv_sec * USEC_PER_SEC + t->tv_nsec / NSEC_PER_USEC;
+}
+
+static inline struct timeval usec_to_timeval(usec_t t)
+{
+ struct timeval r = {
+ .tv_sec = t / USEC_PER_SEC,
+ .tv_usec = t % USEC_PER_SEC,
+ };
+ return r;
+}
+
#endif /* UTIL_LINUX_TIME_UTIL_H */