1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
diff -Nur xv-3.10a_old/xvevent.c xv-3.10a/xvevent.c
--- xv-3.10a_old/xvevent.c 2008-05-06 12:44:41.000000000 -0600
+++ xv-3.10a/xvevent.c 2008-05-06 15:55:59.000000000 -0600
@@ -82,7 +82,7 @@
int retval,done,waiting;
#ifdef USE_TICKS
clock_t waitsec_ticks=0L, orgtime_ticks=0L, curtime_ticks;
- clock_t elapsed_ticks=0L, remaining_interval;
+ clock_t elapsed_ticks=0L, remaining_interval, clock_ticks_per_sec;
#else
time_t orgtime=0L, curtime;
#endif
@@ -126,7 +126,8 @@
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);
+ clock_ticks_per_sec = sysconf(_SC_CLK_TCK);
+ waitsec_ticks = (clock_t)(waitsec * clock_ticks_per_sec);
orgtime_ticks = times(NULL); /* unclear if NULL valid, but OK on Linux */
#else
orgtime = time(NULL);
@@ -168,11 +169,14 @@
} 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_ticks_per_sec)
sleep(1);
else {
- /* less than one second remaining: do delay in msec, then return */
- Timer((remaining_interval * 1000L) / CLK_TCK); /* can't overflow */
+ if (remaining_interval > 0) {
+ /* less than one second remaining: do delay in msec, then return */
+ Timer((remaining_interval * 1000L) / clock_ticks_per_sec); /* can't overflow */
+ }
+
return waitloop? NEXTLOOP : NEXTQUIT;
}
#else
|