mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-02 18:31:12 +02:00
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:
@@ -1,3 +1,4 @@
|
|||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h> /* for perror */
|
#include <stdio.h> /* for perror */
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -27,3 +28,14 @@ time_t time_monotonic(void)
|
|||||||
time comparisons if the uptime is low, so add 7 days */
|
time comparisons if the uptime is low, so add 7 days */
|
||||||
return t.tv_sec + 604800;
|
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;
|
||||||
|
}
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef _ABS_TIME_H_
|
#ifndef _ABS_TIME_H_
|
||||||
#define _ABS_TIME_H_
|
#define _ABS_TIME_H_
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -6,6 +8,7 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
extern time_t time_monotonic_ms(void);
|
extern time_t time_monotonic_ms(void);
|
||||||
extern time_t time_monotonic(void);
|
extern time_t time_monotonic(void);
|
||||||
|
uint64_t time_monotonic_us(void);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user