summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-09-26 11:24:52 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-09-26 11:24:52 +0900
commitabf3f1342c581a3964a463f09b1a8e719b7377a4 (patch)
treefd3ee2fd20812d317aa786a327128b5f2057de81 /lib
parent58244658cbe01e7091afba6e8da8764c9b05463d (diff)
downloadshortcut-abf3f1342c581a3964a463f09b1a8e719b7377a4.tar.gz
shortcut-abf3f1342c581a3964a463f09b1a8e719b7377a4.tar.bz2
shortcut-abf3f1342c581a3964a463f09b1a8e719b7377a4.zip
Replace gettimeofday with clock_get_time
Change-Id: I88e8eee0ab2dfd031a807aa4c4c7fb701fdd7cdf
Diffstat (limited to 'lib')
-rw-r--r--lib/CMakeLists.txt1
-rw-r--r--lib/src/icon.c30
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index f02c651..924ab26 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -28,6 +28,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
ADD_DEFINITIONS("-DLOG_TAG=\"SHORTCUT\"")
+ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET")
ADD_LIBRARY(${PROJECT_NAME} SHARED
src/main.c
diff --git a/lib/src/icon.c b/lib/src/icon.c
index 0fb83da..06877fc 100644
--- a/lib/src/icon.c
+++ b/lib/src/icon.c
@@ -24,6 +24,7 @@
#include <sys/ioctl.h>
#include <libgen.h>
#include <sys/time.h>
+#include <time.h>
#include <dlog.h>
#include <glib.h>
@@ -44,7 +45,6 @@
#define CREATED 0x00BEEF00
#define DESTROYED 0x00DEAD00
-
static struct info {
int fd;
int (*init_cb)(int status, void *data);
@@ -54,6 +54,9 @@ static struct info {
const char *utility_socket;
struct dlist *pending_list;
+#if defined(_USE_ECORE_TIME_GET)
+ clockid_t type;
+#endif
} s_info = {
.fd = -1,
.init_cb = NULL,
@@ -62,6 +65,9 @@ static struct info {
.utility_socket = "/tmp/.utility.service",
.pending_list = NULL,
+#if defined(_USE_ECORE_TIME_GET)
+ .type = CLOCK_MONOTONIC,
+#endif
};
@@ -672,7 +678,6 @@ EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type,
struct packet *packet;
struct request_item *item;
char *filename;
- struct timeval tv;
int len;
if (!handle || handle->state != CREATED) {
@@ -695,6 +700,26 @@ EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type,
return -ENOMEM;
}
+#if defined(_USE_ECORE_TIME_GET)
+ struct timespec ts;
+ double tv;
+ do {
+ if (clock_gettime(s_info.type, &ts) == 0) {
+ tv = ts.tv_sec + ts.tv_nsec / 1000000000.0f;
+ break;
+ }
+
+ ErrPrint("%d: %s\n", s_info.type, strerror(errno));
+ if (s_info.type == CLOCK_MONOTONIC) {
+ s_info.type = CLOCK_REALTIME;
+ } else if (s_info.type == CLOCK_REALTIME) {
+ tv = rand();
+ break;
+ }
+ } while (1);
+ ret = snprintf(filename, len, "%s.%lf.desc", outfile, tv);
+#else
+ struct timeval tv;
if (gettimeofday(&tv, NULL) != 0) {
ErrPrint("gettimeofday: %s\n", strerror(errno));
tv.tv_sec = rand();
@@ -702,6 +727,7 @@ EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type,
}
ret = snprintf(filename, len, "%s.%lu.%lu.desc", outfile, tv.tv_sec, tv.tv_usec);
+#endif
if (ret < 0) {
ErrPrint("snprintf: %s\n", strerror(errno));
goto out;