chiark / gitweb /
udevd: clarify worker exit status
[elogind.git] / libudev / libudev-util.c
index 6c309afd0536798fe3a1e81dffb2b68d4bb7a591..48eea0b8981282bd25d692de973293910be4c6f3 100644 (file)
@@ -18,6 +18,7 @@
 #include <dirent.h>
 #include <ctype.h>
 #include <fcntl.h>
+#include <time.h>
 #include <sys/stat.h>
 
 #include "libudev.h"
@@ -553,3 +554,15 @@ uint64_t util_string_bloom64(const char *str)
        bits |= 1LLU << ((hash >> 18) & 63);
        return bits;
 }
+
+#define USEC_PER_SEC  1000000ULL
+#define NSEC_PER_USEC 1000ULL
+unsigned long long now_usec(void)
+{
+       struct timespec ts;
+
+       if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
+               return 0;
+       return (unsigned long long) ts.tv_sec * USEC_PER_SEC +
+              (unsigned long long) ts.tv_nsec / NSEC_PER_USEC;
+}