+
+#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;
+}