]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
util: add helper function to compare timestamps
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Sat, 31 Dec 2011 14:28:54 +0000 (12:28 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Sun, 1 Jan 2012 08:17:54 +0000 (06:17 -0200)
libkmod/libkmod-util.c
libkmod/libkmod-util.h

index d402cdda591334ceabc9ae6526c6a38267d4183d..a86eda39c377ec2afc099d66127116106891708f 100644 (file)
@@ -319,3 +319,11 @@ char *path_make_absolute_cwd(const char *p)
 
        return r;
 }
+
+#define USEC_PER_SEC  1000000ULL
+#define NSEC_PER_USEC 1000ULL
+unsigned long long ts_usec(const struct timespec *ts)
+{
+       return (unsigned long long) ts->tv_sec * USEC_PER_SEC +
+              (unsigned long long) ts->tv_nsec / NSEC_PER_USEC;
+}
index a426715171f980477acd763c5b0d4ce44a220ecb..3cd352c88fd597a010bda1f84c3d179832743f3f 100644 (file)
@@ -23,5 +23,6 @@ char *path_make_absolute_cwd(const char *p) __must_check __attribute__((nonnull(
 int alias_normalize(const char *alias, char buf[NAME_MAX], size_t *len) __must_check __attribute__((nonnull(1,2)));
 char *modname_normalize(const char *modname, char buf[NAME_MAX], size_t *len) __attribute__((nonnull(1, 2)));
 char *path_to_modname(const char *path, char buf[NAME_MAX], size_t *len) __attribute__((nonnull(2)));
+unsigned long long ts_usec(const struct timespec *ts);
 
 #endif