From dc729bb9da6a47b09322486ff6859c4ad7d83144 Mon Sep 17 00:00:00 2001 From: Chaskiel M Grundman Date: Sun, 20 Mar 2005 19:40:32 +0000 Subject: [PATCH] STABLE14-amd64-linux-rx-clock-fix-20050320 FIXES 17950 avoid initial delay in rx on amd64 linux due to interval timer issue (cherry picked from commit 70a8bba77b7e03d29edd8fab9b1cac098d1a7338) --- src/rx/rx_clock.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rx/rx_clock.c b/src/rx/rx_clock.c index 63213fcf3..06d6a5912 100644 --- a/src/rx/rx_clock.c +++ b/src/rx/rx_clock.c @@ -54,6 +54,7 @@ RCSID #else #define STARTVALUE 100000000 /* Max number of seconds setitimer allows, for some reason */ #endif +static int startvalue = STARTVALUE; struct clock clock_now; /* The last elapsed time ready by clock_GetTimer */ @@ -81,6 +82,10 @@ clock_Init(void) fflush(stderr); exit(1); } + getitimer(ITIMER_REAL, &itimer); + startvalue = itimer.it_value.tv_sec; + if (itimer.it_value.tv_usec > 0) + startvalue++; clockInitialized = 1; } @@ -101,7 +106,7 @@ clock_UpdateTime(void) { struct itimerval itimer; getitimer(ITIMER_REAL, &itimer); - clock_now.sec = STARTVALUE - 1 - itimer.it_value.tv_sec; /* The "-1" makes up for adding 1000000 usec, on the next line */ + clock_now.sec = startvalue - 1 - itimer.it_value.tv_sec; /* The "-1" makes up for adding 1000000 usec, on the next line */ clock_now.usec = 1000000 - itimer.it_value.tv_usec; if (clock_now.usec == 1000000) clock_now.usec = 0, clock_now.sec++; -- 2.39.5