mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-02 10:21:10 +02:00
add functions to get monotonic timestamps (needs kernel 2.6)
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1251 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -16,6 +16,7 @@ INCLUDES = \
|
|||||||
noinst_LIBRARIES = libneutrino_driver.a libneutrino_driver_netfile.a
|
noinst_LIBRARIES = libneutrino_driver.a libneutrino_driver_netfile.a
|
||||||
|
|
||||||
libneutrino_driver_a_SOURCES = \
|
libneutrino_driver_a_SOURCES = \
|
||||||
|
abstime.c \
|
||||||
encoding.cpp \
|
encoding.cpp \
|
||||||
fontrenderer.cpp \
|
fontrenderer.cpp \
|
||||||
framebuffer.cpp \
|
framebuffer.cpp \
|
||||||
|
27
src/driver/abstime.c
Normal file
27
src/driver/abstime.c
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include <stdio.h> /* for perror */
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
time_t time_monotonic_ms(void)
|
||||||
|
{
|
||||||
|
struct timespec t;
|
||||||
|
time_t ret;
|
||||||
|
if (clock_gettime(CLOCK_MONOTONIC, &t))
|
||||||
|
{
|
||||||
|
perror("time_monotonic_ms clock_gettime");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ret = (t.tv_sec & 0x01FFFFF) * 1000; /* avoid overflow */
|
||||||
|
ret += t.tv_nsec / 1000000;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t time_monotonic(void)
|
||||||
|
{
|
||||||
|
struct timespec t;
|
||||||
|
if (clock_gettime(CLOCK_MONOTONIC, &t))
|
||||||
|
{
|
||||||
|
perror("time_monotonic clock_gettime");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return t.tv_sec;
|
||||||
|
}
|
12
src/driver/abstime.h
Normal file
12
src/driver/abstime.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef _ABS_TIME_H_
|
||||||
|
#define _ABS_TIME_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
extern time_t time_monotonic_ms(void);
|
||||||
|
extern time_t time_monotonic(void);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
Reference in New Issue
Block a user