[Spice-devel] [PATCH v3 1/3] stat: fix portability problem in stat_time_t declaration
Frediano Ziglio
fziglio at redhat.com
Wed Dec 9 07:58:58 PST 2015
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>
---
server/stat.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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)
--
2.4.3
More information about the Spice-devel
mailing list