summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-09-26 11:46:27 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-09-26 11:46:27 +0900
commit753e1a25231c7890dfdd4ccfb8d0fcdc11beda27 (patch)
treede2ea6609762c55f52623069f6b873c5bee7286c
parent185975d7504772f16cf449036c8430f8867f8c7d (diff)
downloadlivebox-service-753e1a25231c7890dfdd4ccfb8d0fcdc11beda27.tar.gz
livebox-service-753e1a25231c7890dfdd4ccfb8d0fcdc11beda27.tar.bz2
livebox-service-753e1a25231c7890dfdd4ccfb8d0fcdc11beda27.zip
Try to use gettimeofday if clock_gettime is failed
Change-Id: I2031a9cb66d59d50787c67823692f91069233098
-rw-r--r--src/util.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index d78e3bf..133878b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -30,11 +30,13 @@
#include "livebox-errno.h"
int errno;
+#if defined(_USE_ECORE_TIME_GET)
static struct {
clockid_t type;
} s_info = {
.type = CLOCK_MONOTONIC,
};
+#endif
static inline char *check_native_livebox(const char *pkgname)
{
@@ -110,6 +112,7 @@ int util_validate_livebox_package(const char *pkgname)
double util_timestamp(void)
{
+#if defined(_USE_ECORE_TIME_GET)
struct timespec ts;
do {
@@ -121,11 +124,28 @@ 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);
return 0.0f;
+#else
+ struct timeval tv;
+
+ if (gettimeofday(&tv, NULL) < 0) {
+ ErrPrint("gettimeofday: %s\n", strerror(errno));
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ }
+
+ return tv.tv_sec + tv.tv_usec / 1000000.0f;
+#endif
}
const char *util_basename(const char *name)