[hackers] [st] Fixed wrong nanosecond factor 10E6. || Ivan Delalande

From: <git_AT_suckless.org>
Date: Thu, 26 Jun 2014 12:34:57 +0200

commit 19d095717f656d844cd9d696d9c921a0821a5ea7
Author: Ivan Delalande <colona_AT_ycc.fr>
Date: Thu Jun 26 04:30:43 2014 +0200

    Fixed wrong nanosecond factor 10E6.
    
    Commit 5edeec1 introduced a wrong factor for nanosecond computation, the correct
    value is 1E6. Time and timeout values are 10 times less than they should be and
    this cause high CPU usage.
    
    Reported by pyroh on IRC. Thanks!
    
    Signed-off-by: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>

diff --git a/st.c b/st.c
index 17142a4..f9c9f7a 100644
--- a/st.c
+++ b/st.c
_AT_@ -76,7 +76,7 @@ char *argv0;
 #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
 #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg)
 #define IS_SET(flag) ((term.mode & (flag)) != 0)
-#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_nsec-t2.tv_nsec)/10E6)
+#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_nsec-t2.tv_nsec)/1E6)
 #define CEIL(x) (((x) != (int) (x)) ? (x) + 1 : (x))
 #define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
 
_AT_@ -3753,7 +3753,7 @@ run(void) {
 
                 clock_gettime(CLOCK_MONOTONIC, &now);
                 drawtimeout.tv_sec = 0;
- drawtimeout.tv_nsec = (1000/xfps) * 10E6;
+ drawtimeout.tv_nsec = (1000/xfps) * 1E6;
                 tv = &drawtimeout;
 
                 dodraw = 0;
_AT_@ -3790,7 +3790,7 @@ run(void) {
> blinktimeout) {
                                                 drawtimeout.tv_nsec = 1000;
                                         } else {
- drawtimeout.tv_nsec = (10E6 * \
+ drawtimeout.tv_nsec = (1E6 * \
                                                         (blinktimeout - \
                                                         TIMEDIFF(now,
                                                                 lastblink)));
Received on Thu Jun 26 2014 - 12:34:57 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 26 2014 - 12:36:16 CEST