From: Sung-jae Park Date: Thu, 26 Sep 2013 03:32:05 +0000 (+0900) Subject: Try to use gettimeofday if clock_gettime is failed X-Git-Tag: accepted/tizen/20131022.083701^2~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fframework%2Fweb%2Flivebox-viewer.git;a=commitdiff_plain;h=f26e7046c83c93394016772990deb13f8b8a357b Try to use gettimeofday if clock_gettime is failed Change-Id: Ibb27603e81867ff06a104adf2e901190fc1e9430 --- diff --git a/src/util.c b/src/util.c index c58b4f2..66431c6 100644 --- a/src/util.c +++ b/src/util.c @@ -67,7 +67,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); @@ -75,7 +81,12 @@ double util_timestamp(void) #else struct timeval tv; - gettimeofday(&tv, NULL); + if (gettimeofday(&tv, NULL) < 0) { + ErrPrint("gettimeofday: %s\n", strerror(errno)); + tv.tv_sec = 0; + tv.tv_usec = 0; + } + return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; #endif }