[Spice-commits] server/stat.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed Dec 9 09:03:24 PST 2015


 server/stat.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 4173663ea17787537e6722551852e046c225d130
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Dec 2 11:27:13 2015 +0000

    stat: fix portability problem in stat_time_t declaration
    
    Assure stat_time_t is 64 bit on all architectures.
    long is not 64 bit on 32 bit systems so use uint64_t intead.
    Also avoid 32 bit overflows for such architectures.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/stat.h b/server/stat.h
index 77bfc69..5e8fc32 100644
--- a/server/stat.h
+++ b/server/stat.h
@@ -43,14 +43,14 @@ void stat_remove_counter(uint64_t *counter);
 #define stat_inc_counter(c, v)
 #endif /* RED_STATISTICS */
 
-typedef unsigned long stat_time_t;
+typedef uint64_t stat_time_t;
 
 static inline stat_time_t stat_now(clockid_t clock_id)
 {
     struct timespec ts;
 
     clock_gettime(clock_id, &ts);
-    return ts.tv_nsec + ts.tv_sec * 1000 * 1000 * 1000;
+    return ts.tv_nsec + (uint64_t) ts.tv_sec * (1000 * 1000 * 1000);
 }
 
 static inline double stat_cpu_time_to_sec(stat_time_t time)


More information about the Spice-commits mailing list