diff options
author | Sung-jae Park <nicesj.park@samsung.com> | 2013-09-26 11:45:06 +0900 |
---|---|---|
committer | Sung-jae Park <nicesj.park@samsung.com> | 2013-09-26 11:45:06 +0900 |
commit | 4a48be6de07cddd4ac593581c3e8cb41c187a100 (patch) | |
tree | 87f589ce16942946e6321d31fe8db9ee811f331c /src | |
parent | cf298d9af6b972635851e366b0b08adfedbc367a (diff) | |
download | com-core-4a48be6de07cddd4ac593581c3e8cb41c187a100.tar.gz com-core-4a48be6de07cddd4ac593581c3e8cb41c187a100.tar.bz2 com-core-4a48be6de07cddd4ac593581c3e8cb41c187a100.zip |
Try to use the gettimeofday if clock_gettime is failed
Change-Id: Iceda877ff4fee12b3fe702aeb3c904b043258a96
Diffstat (limited to 'src')
-rw-r--r-- | src/util.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -61,7 +61,13 @@ double util_timestamp(void) if (s_info.type == CLOCK_MONOTONIC) { s_info.type = CLOCK_REALTIME; } else if (s_info.type == CLOCK_REALTIME) { - break; + struct timeval tv; + if (gettimeofday(&tv, NULL) < 0) { + ErrPrint("gettimeofday: %s\n", strerror(errno)); + break; + } + + return tv.tv_sec + tv.tv_usec / 1000000.0f; } } while (1); @@ -71,8 +77,8 @@ double util_timestamp(void) if (gettimeofday(&tv, NULL) < 0) { ErrPrint("gettimeofday: %s\n", strerror(errno)); - tv.tv_sec = rand(); - tv.tv_usec = rand(); + tv.tv_sec = 0; + tv.tv_usec = 0; } return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; |