Skip to content
Snippets Groups Projects
Commit ab402ebc authored by deuce's avatar deuce
Browse files

Clean up internal timer functions.

parent 627f0464
Branches
Tags
No related merge requests found
...@@ -579,8 +579,7 @@ void ODTimerStart(tODTimer *pTimer, tODMilliSec Duration) ...@@ -579,8 +579,7 @@ void ODTimerStart(tODTimer *pTimer, tODMilliSec Duration)
#ifdef ODPLAT_NIX #ifdef ODPLAT_NIX
gettimeofday(&tv,NULL); gettimeofday(&tv,NULL);
pTimer->Start_sec=tv.tv_sec; pTimer->Start=(long long)tv.tv_sec*1000+tv.tv_usec/1000;
pTimer->Start_usec=tv.tv_usec;
pTimer->Duration = Duration; pTimer->Duration = Duration;
#endif #endif
} }
...@@ -654,19 +653,7 @@ void ODTimerWaitForElapse(tODTimer *pTimer) ...@@ -654,19 +653,7 @@ void ODTimerWaitForElapse(tODTimer *pTimer)
#elif defined(ODPLAT_NIX) #elif defined(ODPLAT_NIX)
/* This is timing sensitive and *MUST* wait regardless of 100% CPU or signals */ /* This is timing sensitive and *MUST* wait regardless of 100% CPU or signals */
while(1) { od_sleep(ODTimerLeft(pTimer));
gettimeofday(&tv,NULL);
tv.tv_sec -= (pTimer->Start_sec + pTimer->Duration/1000);
tv.tv_usec -= (pTimer->Start_usec + ((pTimer->Duration*1000)%1000000));
if(tv.tv_usec < 0) {
tv.tv_sec--;
tv.tv_usec += 1000000;
}
if(tv.tv_sec<0 || tv.tv_usec<0)
return;
if(!select(0,NULL,NULL,NULL,&tv))
break;
}
#else /* !ODPLAT_DOS */ #else /* !ODPLAT_DOS */
{ {
/* Under other platforms, timer resolution is high enough that we can */ /* Under other platforms, timer resolution is high enough that we can */
...@@ -731,13 +718,7 @@ tODMilliSec ODTimerLeft(tODTimer *pTimer) ...@@ -731,13 +718,7 @@ tODMilliSec ODTimerLeft(tODTimer *pTimer)
} }
#elif defined(ODPLAT_NIX) #elif defined(ODPLAT_NIX)
gettimeofday(&tv,NULL); gettimeofday(&tv,NULL);
tv.tv_sec -= pTimer->Start_sec; left=(long long)tv.tv_sec*1000+tv.tv_usec/1000-pTimer->Start;
tv.tv_usec -= pTimer->Start_usec;
if(tv.tv_usec < 0) {
tv.tv_sec--;
tv.tv_usec += 1000000;
}
left=(tv.tv_usec/1000)+(tv.tv_sec*1000);
if(left<0) if(left<0)
left=0; left=0;
return(left); return(left);
......
...@@ -72,8 +72,7 @@ typedef struct ...@@ -72,8 +72,7 @@ typedef struct
clock_t Start; clock_t Start;
clock_t Duration; clock_t Duration;
#elif defined(ODPLAT_NIX) #elif defined(ODPLAT_NIX)
long Start_sec; long long Start;
long Start_usec;
tODMilliSec Duration; tODMilliSec Duration;
#else /* !ODPLAT_DOS */ #else /* !ODPLAT_DOS */
tODMilliSec Start; tODMilliSec Start;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment