mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-03 10:51:12 +02:00
change time_monotonic_ms() from time_t to int64_t
time_monotonic_ms values did wrap every ~24 days, leading to problems in code that did not cope with that. Instead of fixing all places where relative comparisons with time_monotonic_ms() are made, just use a bigger datatype. Convert all users to the new type.
This commit is contained in:
committed by
Jacek Jendrzej
parent
ea30b22119
commit
99c8168d2c
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h> /* for perror */
|
||||
#include <time.h>
|
||||
|
||||
time_t time_monotonic_ms(void)
|
||||
int64_t time_monotonic_ms(void)
|
||||
{
|
||||
struct timespec t;
|
||||
time_t ret;
|
||||
@@ -11,7 +11,7 @@ time_t time_monotonic_ms(void)
|
||||
perror("time_monotonic_ms clock_gettime");
|
||||
return -1;
|
||||
}
|
||||
ret = ((t.tv_sec + 604800)& 0x01FFFFF) * 1000; /* avoid overflow */
|
||||
ret = (t.tv_sec + 604800) * (int64_t)1000; /* avoid overflow */
|
||||
ret += t.tv_nsec / 1000000;
|
||||
return ret;
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
extern time_t time_monotonic_ms(void);
|
||||
extern time_t time_monotonic(void);
|
||||
time_t time_monotonic(void);
|
||||
int64_t time_monotonic_ms(void);
|
||||
uint64_t time_monotonic_us(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <glfb.h>
|
||||
extern GLFramebuffer *glfb;
|
||||
@@ -115,18 +116,18 @@ void CFbAccelGLFB::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32
|
||||
void CFbAccelGLFB::run()
|
||||
{
|
||||
printf(LOGTAG "run start\n");
|
||||
time_t last_blit = 0;
|
||||
int64_t last_blit = INT64_MAX;
|
||||
blit_pending = false;
|
||||
blit_thread = true;
|
||||
blit_mutex.lock();
|
||||
set_threadname("glfb::autoblit");
|
||||
while (blit_thread) {
|
||||
blit_cond.wait(&blit_mutex, blit_pending ? BLIT_INTERVAL_MIN : BLIT_INTERVAL_MAX);
|
||||
time_t now = time_monotonic_ms();
|
||||
int64_t now = time_monotonic_ms();
|
||||
if (now - last_blit < BLIT_INTERVAL_MIN)
|
||||
{
|
||||
blit_pending = true;
|
||||
//printf(LOGTAG "run: skipped, time %ld\n", now - last_blit);
|
||||
//printf(LOGTAG "run: skipped, time %" PRId64 "\n", now - last_blit);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <linux/kd.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -330,18 +331,19 @@ void CFbAccelSTi::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_
|
||||
void CFbAccelSTi::run()
|
||||
{
|
||||
printf(LOGTAG "::run start\n");
|
||||
time_t last_blit = 0;
|
||||
int64_t last_blit = INT64_MAX; /* blit at first iteration */
|
||||
blit_pending = false;
|
||||
blit_thread = true;
|
||||
blit_mutex.lock();
|
||||
set_threadname("stifb::autoblit");
|
||||
while (blit_thread) {
|
||||
blit_cond.wait(&blit_mutex, blit_pending ? BLIT_INTERVAL_MIN : BLIT_INTERVAL_MAX);
|
||||
time_t now = time_monotonic_ms();
|
||||
if (now - last_blit < BLIT_INTERVAL_MIN)
|
||||
int64_t now = time_monotonic_ms();
|
||||
int64_t diff = now - last_blit;
|
||||
if (diff < BLIT_INTERVAL_MIN)
|
||||
{
|
||||
blit_pending = true;
|
||||
//printf(LOGTAG "::run: skipped, time %ld\n", now - last_blit);
|
||||
//printf(LOGTAG "::run: skipped, time %" PRId64 "\n", diff);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -367,9 +369,9 @@ void CFbAccelSTi::blit()
|
||||
void CFbAccelSTi::_blit()
|
||||
{
|
||||
#if 0
|
||||
static time_t last = 0;
|
||||
time_t now = time_monotonic_ms();
|
||||
printf("%s %ld\n", __func__, now - last);
|
||||
static int64_t last = 0;
|
||||
int64_t now = time_monotonic_ms();
|
||||
printf("%s %" PRId64 "\n", __func__, now - last);
|
||||
last = now;
|
||||
#endif
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||
|
Reference in New Issue
Block a user