driver/abstime.c: add time_monotonic_us

Origin commit data
------------------
Branch: ni/coolstream
Commit: e7c5d8925f
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-03-05 (Mon, 05 Mar 2012)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2012-03-05 19:59:39 +04:00
parent 61846fb574
commit 833e12d338
2 changed files with 15 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h> /* for perror */
#include <time.h>
@@ -27,3 +28,14 @@ time_t time_monotonic(void)
time comparisons if the uptime is low, so add 7 days */
return t.tv_sec + 604800;
}
uint64_t time_monotonic_us(void)
{
struct timespec t;
if (clock_gettime(CLOCK_MONOTONIC, &t))
{
perror("time_monotonic_us clock_gettime");
return -1;
}
return ((int64_t)t.tv_sec + (uint64_t)604800) * (uint64_t) 1000000 + (uint64_t) t.tv_nsec / (uint64_t)1000;
}