]> wimlib.net Git - wimlib/blobdiff - src/timestamp.h
Decompression optimizations
[wimlib] / src / timestamp.h
index 9c82c23e2081dab9d8f3212bfd6c8e5ba1286a92..406f6a5db7f34f929b4f6dc4492bef0556a96c78 100644 (file)
@@ -3,6 +3,8 @@
 
 #include "util.h"
 #include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
 
 #define intervals_per_second (1000000000ULL / 100ULL)
 #define intervals_per_microsecond (10)
@@ -36,6 +38,13 @@ static inline u64 timeval_to_wim_timestamp(const struct timeval *tv)
               + (u64)tv->tv_usec * intervals_per_microsecond;
 }
 
+static inline void wim_timestamp_to_timeval(u64 timestamp, struct timeval *tv)
+{
+       tv->tv_sec = (timestamp - intervals_1601_to_1970) / intervals_per_second;
+       tv->tv_usec = ((timestamp - intervals_1601_to_1970) /
+                       intervals_per_microsecond) % 1000000;
+}
+
 static inline u64 timespec_to_wim_timestamp(const struct timespec *ts)
 {
        return intervals_1601_to_1970
@@ -44,5 +53,6 @@ static inline u64 timespec_to_wim_timestamp(const struct timespec *ts)
 }
 
 extern u64 get_wim_timestamp();
+extern void wim_timestamp_to_str(u64 timestamp, char *buf, size_t len);
 
 #endif