Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Commit

Permalink
Use correct tick definition of the system instead of a hard-defined v…
Browse files Browse the repository at this point in the history
…alue.

This is from xv-20091215-werner-fink-multiple-fixes.patch.mime.
CLK_TCK isn't defined anymore on newer Linux systems as it now becomes
variable at boot time.  I need to revisit this after this patch-a-thon
to make sure that if CLK_TCK is indeed defined, then we should use that
so as to keep backwards compatibility.
  • Loading branch information
DavidGriffith committed Apr 28, 2017
1 parent a1d499e commit 25683ef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions xvevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int EventLoop()
#ifdef USE_TICKS
clock_t waitsec_ticks=0L, orgtime_ticks=0L, curtime_ticks;
clock_t elapsed_ticks=0L, remaining_interval;
clock_t clock_ticks = sysconf(_SC_CLK_TCK);
#else
time_t orgtime=0L, curtime;
#endif
Expand Down Expand Up @@ -135,7 +136,7 @@ int EventLoop()
all pending events (ie, drawing the image the first time)
have been dealt with: START WAITING */
#ifdef USE_TICKS
waitsec_ticks = (clock_t)(waitsec * CLK_TCK);
waitsec_ticks = (clock_t)(waitsec * clock_ticks);
orgtime_ticks = times(NULL); /* unclear if NULL valid, but OK on Linux */
#else
orgtime = time(NULL);
Expand Down Expand Up @@ -181,11 +182,11 @@ int EventLoop()
} else
elapsed_ticks = curtime_ticks - orgtime_ticks;
remaining_interval = waitsec_ticks - elapsed_ticks;
if (remaining_interval >= (clock_t)(1 * CLK_TCK))
if (remaining_interval >= (clock_t)(1 * clock_ticks))
sleep(1);
else {
/* less than one second remaining: do delay in msec, then return */
Timer((remaining_interval * 1000L) / CLK_TCK); /* can't overflow */
Timer((remaining_interval * 1000L) / clock_ticks); /* can't overflow */
return waitloop? NEXTLOOP : NEXTQUIT;
}
#else
Expand Down

0 comments on commit 25683ef

Please sign in to comment.