From 39b0a94eb2ae8c687084bff6d7dae23458388b58 Mon Sep 17 00:00:00 2001 From: Yu Qing Date: Tue, 2 Feb 2016 16:37:31 +0800 Subject: [PATCH] set tv_usec 0 in Linux --- src/system_info.c | 2 ++ src/tests/test_mblock.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/system_info.c b/src/system_info.c index 162d140..b2c0d02 100644 --- a/src/system_info.c +++ b/src/system_info.c @@ -112,6 +112,7 @@ int get_boot_time(struct timeval *boot_time) gettimeofday(¤t_time, NULL); btime = TIMEVAL_TO_SECONDS(current_time) - uptime; SECONDS_TO_TIMEVAL(btime, *boot_time); + boot_time->tv_usec = 0; return 0; } } @@ -519,6 +520,7 @@ int get_processes(struct fast_process_info **processes, int *count) SECONDS_TO_TIMEVAL(TIMEVAL_TO_SECONDS(boot_time) + (double)starttime / (double)tickets, proc_array.procs[proc_array.count].starttime); + proc_array.procs[proc_array.count].starttime.tv_usec = 0; proc_array.count++; } diff --git a/src/tests/test_mblock.c b/src/tests/test_mblock.c index 147f5d2..3bbb155 100644 --- a/src/tests/test_mblock.c +++ b/src/tests/test_mblock.c @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) stat("/etc/passwd", &st); printf("file inode: %ld\n", (long)st.st_ino); - printf("file device: %"PRId64"\n", *((int64_t *)&st.st_dev)); + printf("file device: %ld\n", (long)st.st_dev); printf("file access time: %d.%ld\n", (int)st.st_atime, st.st_atimensec); printf("file modify time: %d.%ld\n", (int)st.st_mtime, st.st_mtimensec); printf("file change time: %d.%ld\n", (int)st.st_ctime, st.st_ctimensec);