From 87a5e9ccc313b35b78483a5e92e278bf025259fd Mon Sep 17 00:00:00 2001 From: Jaeho Lee Date: Wed, 25 Sep 2013 13:51:11 +0900 Subject: [PATCH] Change API from time to clock_gettime Signed-off-by: Jaeho Lee Change-Id: Icd6cf363a8176bd970dfc7f7b6b96e28e654c09a --- alarm-manager-schedule.c | 18 +++++++++--------- alarm-manager-timer.c | 13 ++++++++++++- alarm-manager.c | 20 ++++++++++---------- include/alarm-internal.h | 2 ++ packaging/alarm-manager.spec | 2 +- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/alarm-manager-schedule.c b/alarm-manager-schedule.c index a38eaaa..9cedebd 100755 --- a/alarm-manager-schedule.c +++ b/alarm-manager-schedule.c @@ -190,7 +190,7 @@ static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info) alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_date_t *start = &alarm_info->start; - time(¤t_time); + _alarm_time(¤t_time); localtime_r(¤t_time, &duetime_tm); duetime_tm.tm_hour = start->hour; duetime_tm.tm_min = start->min; @@ -222,7 +222,7 @@ static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info) alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_date_t *start = &alarm_info->start; - time(¤t_time); + _alarm_time(¤t_time); /*localtime_r(¤t_time, &duetime_tm); */ duetime_tm.tm_hour = start->hour; @@ -262,7 +262,7 @@ static time_t __alarm_next_duetime_annually(__alarm_info_t *__alarm_info) alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_date_t *start = &alarm_info->start; - time(¤t_time); + _alarm_time(¤t_time); localtime_r(¤t_time, &duetime_tm); duetime_tm.tm_hour = start->hour; duetime_tm.tm_min = start->min; @@ -295,7 +295,7 @@ static time_t __alarm_next_duetime_monthly(__alarm_info_t *__alarm_info) alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_date_t *start = &alarm_info->start; - time(¤t_time); + _alarm_time(¤t_time); localtime_r(¤t_time, &duetime_tm); duetime_tm.tm_hour = start->hour; duetime_tm.tm_min = start->min; @@ -339,7 +339,7 @@ static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info) alarm_mode_t *mode = &alarm_info->mode; - time(¤t_time); + _alarm_time(¤t_time); localtime_r(¤t_time, &duetime_tm); wday = duetime_tm.tm_wday; duetime_tm.tm_hour = start->hour; @@ -405,7 +405,7 @@ time_t _alarm_next_duetime(__alarm_info_t *__alarm_info) alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_mode_t *mode = &alarm_info->mode; - time(¤t_time); + _alarm_time(¤t_time); cur_tm = localtime(¤t_time); if (cur_tm->tm_isdst > 0) is_dst = 1; @@ -459,7 +459,7 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time) GSList *iter = NULL; __alarm_info_t *entry = NULL; - time(¤t_time); + _alarm_time(¤t_time); for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) { @@ -509,7 +509,7 @@ static bool __find_next_alarm_to_be_scheduled_power_on(time_t *min_due_time) struct tm *temp_info; GSList *iter = NULL; - time(¤t_time); + _alarm_time(¤t_time); tzset(); /*for portability tzset() need to be called before locatime_r,refer manpage localtime_r*/ @@ -580,7 +580,7 @@ bool _alarm_schedule() int min = -1; - time(¤t_time); + _alarm_time(¤t_time); min_time = 0; diff --git a/alarm-manager-timer.c b/alarm-manager-timer.c index 5e0f73b..9afeb3e 100755 --- a/alarm-manager-timer.c +++ b/alarm-manager-timer.c @@ -96,7 +96,7 @@ bool _alarm_set_timer(__alarm_server_context_t *alarm_context, timer_t timer, extern int errno; - time(¤t_time); + _alarm_time(¤t_time); interval = difftime(due_time, current_time); ALARM_MGR_LOG_PRINT("[alarm-server][timer]: remain time from " @@ -157,3 +157,14 @@ int _set_time(time_t _time) return 0; } + +time_t _alarm_time(time_t *tp) +{ + struct timespec tspec; + + clock_gettime(CLOCK_REALTIME, &tspec); + + *tp = tspec.tv_sec; + + return *tp; +} diff --git a/alarm-manager.c b/alarm-manager.c index 1871f77..0e3b187 100755 --- a/alarm-manager.c +++ b/alarm-manager.c @@ -626,7 +626,7 @@ static bool __alarm_update_due_time_of_all_items_in_list(double diff_time) ALARM_MGR_LOG_PRINT("entry->due_time is %d\n", entry->due_time); } - time(¤t_time); + _alarm_time(¤t_time); for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) { @@ -763,7 +763,7 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t)); __alarm_generate_alarm_id(__alarm_info, alarm_id); - time(¤t_time); + _alarm_time(¤t_time); if (alarm_context.c_due_time < current_time) { ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time " @@ -919,7 +919,7 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t)); __alarm_generate_alarm_id(__alarm_info, alarm_id); - time(¤t_time); + _alarm_time(¤t_time); ALARM_MGR_LOG_PRINT("[alarm-server]:pid=%d, app_unique_name=%s, " "app_service_name=%s,dst_service_name=%s, c_due_time=%d", \ @@ -1023,7 +1023,7 @@ static bool __alarm_update(int pid, char *app_service_name, alarm_id_t alarm_id, __alarm_set_start_and_end_time(alarm_info, __alarm_info); memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t)); - time(¤t_time); + _alarm_time(¤t_time); if (alarm_context.c_due_time < current_time) { ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time " @@ -1200,7 +1200,7 @@ static bool __alarm_power_on(int app_id, bool on_off, int *error_code) min_time = min_time - 60; - time(¤t_time); + _alarm_time(¤t_time); if (min_time <= current_time) min_time = current_time + 5; @@ -1294,7 +1294,7 @@ static bool __alarm_check_next_duetime(int app_id, int *error_code) time_t current_time; time_t interval; - time(¤t_time); + _alarm_time(¤t_time); interval = ab_due_time - current_time; @@ -1387,7 +1387,7 @@ static void __alarm_expired() time_t current_time; double interval; - time(¤t_time); + _alarm_time(¤t_time); interval = difftime(alarm_context.c_due_time, current_time); ALARM_MGR_LOG_PRINT("[alarm-server]: c_due_time(%d), " @@ -1670,7 +1670,7 @@ static void __on_system_time_changed(keynode_t *node, void *data) vconf_get_int(VCONFKEY_SYSTEM_TIMECHANGE, (int *)&_time); } - time(&before); + _alarm_time(&before); diff_time = difftime(_time, before); tzset(); @@ -1720,7 +1720,7 @@ static void __on_system_time_external_changed(keynode_t *node, void *data) } tzset(); - time(&cur_time); + _alarm_time(&cur_time); ALARM_MGR_EXCEPTION_PRINT("diff_time is %f, New time is %s\n", diff_time, ctime(&cur_time)); @@ -2896,7 +2896,7 @@ static bool __check_false_alarm() time_t current_time; time_t interval; - time(¤t_time); + _alarm_time(¤t_time); interval = ab_due_time - current_time; diff --git a/include/alarm-internal.h b/include/alarm-internal.h index e6e1367..4f65c1f 100755 --- a/include/alarm-internal.h +++ b/include/alarm-internal.h @@ -217,6 +217,8 @@ bool _init_scheduled_alarm_list(); int _set_rtc_time(time_t _time); int _set_sys_time(time_t _time); int _set_time(time_t _time); +time_t _alarm_time(time_t *tp); + #ifdef _DEBUG_MODE_ diff --git a/packaging/alarm-manager.spec b/packaging/alarm-manager.spec index b1b0f26..fa77615 100644 --- a/packaging/alarm-manager.spec +++ b/packaging/alarm-manager.spec @@ -1,5 +1,5 @@ Name: alarm-manager -Version: 0.4.85 +Version: 0.4.86 Release: 1 License: Apache-2.0 Summary: Alarm library -- 2.7.4