summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2015-04-07 13:43:53 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2015-04-07 19:37:53 +0900
commit36381a48ea7340f9489d717c8c8b128a88fb99d0 (patch)
tree432a6d09dfcffaea0357f57fc2e80b004a03ef90
parent1755bafdcddb7514b87a1ca49ce23abe95f5b6eb (diff)
downloaddeviced-36381a48ea7340f9489d717c8c8b128a88fb99d0.tar.gz
deviced-36381a48ea7340f9489d717c8c8b128a88fb99d0.tar.bz2
deviced-36381a48ea7340f9489d717c8c8b128a88fb99d0.zip
deviced: Remove Eina_list codes
Do not use Eina_list anymore. Instead deviced will use glist api in glibc. Change-Id: Ia9a2a8a24baadb14e1b5c6fe02f315c56d9b500c Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
-rwxr-xr-xCMakeLists.txt1
-rw-r--r--src/core/edbus-handler.c2
-rw-r--r--src/core/list.h84
-rw-r--r--src/display/core.c42
-rw-r--r--src/display/lock-detector.c54
-rw-r--r--src/shared/list.h50
6 files changed, 63 insertions, 170 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 10e7be65..60528a8a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,7 +115,6 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/deviced)
SET(PKG_MODULES
ecore
edbus
- eina
vconf
dlog
device-node
diff --git a/src/core/edbus-handler.c b/src/core/edbus-handler.c
index f873b969..c4c2e5e7 100644
--- a/src/core/edbus-handler.c
+++ b/src/core/edbus-handler.c
@@ -218,7 +218,7 @@ int register_edbus_signal_handler(const char *path, const char *interface,
entry->handler = handler;
DD_LIST_PREPEND(edbus_handler_list, entry);
if (!edbus_handler_list) {
- _E("eina_list_prepend failed");
+ _E("dd_list_prepend failed");
free(entry->signal_name);
free(entry);
return -ENOMEM;
diff --git a/src/core/list.h b/src/core/list.h
index d3fa6418..1d2f684c 100644
--- a/src/core/list.h
+++ b/src/core/list.h
@@ -19,83 +19,17 @@
#ifndef __LIST_H__
#define __LIST_H__
-#include <Ecore.h>
-#include <stdio.h>
-
-#define EINA_LIST_APPEND(a, b) \
- a = eina_list_append(a, b)
-
-#define EINA_LIST_REMOVE(a, b) \
- a = eina_list_remove(a, b)
-
-#define EINA_LIST_REMOVE_LIST(a, b) \
- a = eina_list_remove_list(a, b)
-
-#define EINA_LIST_FREE_LIST(a) \
- a = eina_list_free(a)
-
-#define EINA_LIST_PROMOTE_LIST(a, b) \
- a = eina_list_promote_list(a, b)
-
-#ifdef EINA_LIST
-typedef Eina_List dd_list;
-#define DD_LIST_PREPEND(a, b) \
- a = eina_list_prepend(a, b)
-#define DD_LIST_APPEND(a, b) \
- a = eina_list_append(a, b)
-#define DD_LIST_REMOVE(a, b) \
- a = eina_list_remove(a, b)
-#define DD_LIST_LENGTH(a) \
- eina_list_count(a)
-#define DD_LIST_NTH(a, b) \
- eina_list_nth(a, b)
-#define DD_LIST_FREE_LIST(a) \
- a = eina_list_free(a)
-#define DD_LIST_FOREACH(head, elem, node) \
- EINA_LIST_FOREACH(head, elem, node)
-#define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
- EINA_LIST_FOREACH_SAFE(head, elem, elem_next, node)
-
-#else
#include <glib.h>
typedef GList dd_list;
-/*
- cover crash from corrupted double linked list under the glib 2.36.4
- if glib version upper than 2.36.3, exchange it to g_list_remove
-*/
-static inline GList* g_list_check_remove(GList* list, gpointer data)
-{
- GList *temp;
- temp = list;
- if (!temp)
- goto out;
- while (temp != NULL) {
- if (temp->data != data)
- temp = temp->next;
- else {
- if (temp->prev != NULL && temp->prev->next == temp)
- temp->prev->next = temp->next;
- if (temp->next != NULL && temp->next->prev == temp)
- temp->next->prev = temp->prev;
- if (temp == list)
- list = list->next;
- temp->prev = NULL;
- temp->next = NULL;
- g_list_free(list);
- break;
- }
- }
-out:
- return list;
-}
-
#define DD_LIST_PREPEND(a, b) \
a = g_list_prepend(a, (gpointer)b)
#define DD_LIST_APPEND(a, b) \
a = g_list_append(a, (gpointer)b)
#define DD_LIST_REMOVE(a, b) \
a = g_list_remove(a, (gpointer)b)
+#define DD_LIST_REMOVE_LIST(a, b) \
+ a = g_list_remove_link(a, b)
#define DD_LIST_LENGTH(a) \
g_list_length(a)
#define DD_LIST_NTH(a, b) \
@@ -103,12 +37,20 @@ out:
#define DD_LIST_FREE_LIST(a) \
g_list_free(a)
#define DD_LIST_FOREACH(head, elem, node) \
- for (elem = head, node = NULL; elem && ((node = elem->data) != NULL); elem = elem->next, node = NULL)
+ for (elem = head, node = NULL; \
+ elem && ((node = elem->data) != NULL); \
+ elem = elem->next, node = NULL)
#define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
for (elem = head, elem_next = g_list_next(elem), node = NULL; \
elem && ((node = elem->data) != NULL); \
elem = elem_next, elem_next = g_list_next(elem), node = NULL)
-
-#endif
+#define DD_LIST_REVERSE_FOREACH(head, elem, node) \
+ for (elem = g_list_last(head), node = NULL; \
+ elem && ((node = elem->data) != NULL); \
+ elem = g_list_previous(elem), node = NULL)
+#define DD_LIST_REVERSE_FOREACH_SAFE(head, elem, elem_next, node) \
+ for (elem = g_list_last(head), elem_next = g_list_previous(elem), node = NULL; \
+ elem && ((node = elem->data) != NULL); \
+ elem = elem_next, elem_next = g_list_previous(elem), node = NULL)
#endif
diff --git a/src/display/core.c b/src/display/core.c
index 610a56bf..b56a2fff 100644
--- a/src/display/core.c
+++ b/src/display/core.c
@@ -90,7 +90,7 @@ static int custom_change_pid = -1;
static char *custom_change_name;
static int standby_mode = false;
static int standby_state = false;
-static Eina_List *standby_mode_list = NULL;
+static dd_list *standby_mode_list;
static int (*basic_action) (int);
static bool hallic_open = true;
static Ecore_Timer *lock_timeout_id;
@@ -98,7 +98,7 @@ static int lock_screen_timeout = LOCK_SCREEN_INPUT_TIMEOUT;
static struct timeval lcdon_tv;
static int lcd_paneloff_mode = false;
static int stay_touchscreen_off = false;
-static Eina_List *lcdon_ops = NULL;
+static dd_list *lcdon_ops;
static bool lcdon_broadcast = false;
/* default transition, action fuctions */
@@ -276,7 +276,7 @@ static unsigned long get_lcd_on_flags(void)
void lcd_on_procedure(int state, enum device_flags flag)
{
- Eina_List *l = NULL;
+ dd_list *l = NULL;
const struct device_ops *ops = NULL;
unsigned long flags = get_lcd_on_flags();
flags |= flag;
@@ -295,7 +295,7 @@ void lcd_on_procedure(int state, enum device_flags flag)
backlight_ops.update();
}
- EINA_LIST_FOREACH(lcdon_ops, l, ops)
+ DD_LIST_FOREACH(lcdon_ops, l, ops)
ops->start(flags);
if (CHECK_OPS(keyfilter_ops, backlight_enable))
@@ -304,7 +304,7 @@ void lcd_on_procedure(int state, enum device_flags flag)
inline void lcd_off_procedure(void)
{
- Eina_List *l = NULL;
+ dd_list *l = NULL;
const struct device_ops *ops = NULL;
unsigned long flags = NORMAL_MODE;
@@ -320,7 +320,7 @@ inline void lcd_off_procedure(void)
if (CHECK_OPS(keyfilter_ops, backlight_enable))
keyfilter_ops->backlight_enable(false);
- EINA_LIST_REVERSE_FOREACH(lcdon_ops, l, ops)
+ DD_LIST_REVERSE_FOREACH(lcdon_ops, l, ops)
ops->stop(flags);
}
@@ -877,17 +877,17 @@ static int standby_action(int timeout)
static void set_standby_mode(pid_t pid, int enable)
{
- Eina_List *l = NULL;
- Eina_List *l_next = NULL;
+ dd_list *l = NULL;
+ dd_list *l_next = NULL;
void *data;
if (enable) {
- EINA_LIST_FOREACH(standby_mode_list, l, data)
+ DD_LIST_FOREACH(standby_mode_list, l, data)
if (pid == (pid_t)((intptr_t)data)) {
_E("%d already acquired standby mode", pid);
return;
}
- EINA_LIST_APPEND(standby_mode_list, (void *)((intptr_t)pid));
+ DD_LIST_APPEND(standby_mode_list, (void *)((intptr_t)pid));
_I("%d acquire standby mode", pid);
if (standby_mode)
return;
@@ -899,9 +899,9 @@ static void set_standby_mode(pid_t pid, int enable)
} else {
if (!standby_mode)
return;
- EINA_LIST_FOREACH_SAFE(standby_mode_list, l, l_next, data)
+ DD_LIST_FOREACH_SAFE(standby_mode_list, l, l_next, data)
if (pid == (pid_t)((intptr_t)data)) {
- standby_mode_list = eina_list_remove_list(
+ standby_mode_list = DD_LIST_REMOVE_LIST(
standby_mode_list, l);
_I("%d release standby mode", pid);
}
@@ -1302,7 +1302,7 @@ void print_info(int fd)
int s_index = 0;
char buf[255];
int i = 1, ret;
- Eina_List *l = NULL;
+ dd_list *l = NULL;
void *data;
char pname[PATH_MAX];
@@ -1351,7 +1351,7 @@ void print_info(int fd)
snprintf(buf, sizeof(buf), "\n\nstandby mode is on\n");
write(fd, buf, strlen(buf));
- EINA_LIST_FOREACH(standby_mode_list, l, data) {
+ DD_LIST_FOREACH(standby_mode_list, l, data) {
get_pname((pid_t)((intptr_t)data), pname);
snprintf(buf, sizeof(buf),
" standby mode acquired by pid %d"
@@ -1994,25 +1994,25 @@ static void init_lcd_operation(void)
ops = find_device("display");
if (!check_default(ops))
- EINA_LIST_APPEND(lcdon_ops, ops);
+ DD_LIST_APPEND(lcdon_ops, ops);
ops = find_device("touchscreen");
if (!check_default(ops))
- EINA_LIST_APPEND(lcdon_ops, ops);
+ DD_LIST_APPEND(lcdon_ops, ops);
ops = find_device("touchkey");
if (!check_default(ops))
- EINA_LIST_APPEND(lcdon_ops, ops);
+ DD_LIST_APPEND(lcdon_ops, ops);
}
static void exit_lcd_operation(void)
{
- Eina_List *l = NULL;
- Eina_List *l_next = NULL;
+ dd_list *l = NULL;
+ dd_list *l_next = NULL;
const struct device_ops *ops = NULL;
- EINA_LIST_FOREACH_SAFE(lcdon_ops, l, l_next, ops)
- EINA_LIST_REMOVE_LIST(lcdon_ops, l);
+ DD_LIST_FOREACH_SAFE(lcdon_ops, l, l_next, ops)
+ DD_LIST_REMOVE_LIST(lcdon_ops, l);
}
enum {
diff --git a/src/display/lock-detector.c b/src/display/lock-detector.c
index 91c486e4..7a79d23a 100644
--- a/src/display/lock-detector.c
+++ b/src/display/lock-detector.c
@@ -30,7 +30,6 @@
#include <sys/time.h>
#include <unistd.h>
#include <sys/types.h>
-#include <Eina.h>
#include "util.h"
#include "core.h"
@@ -48,7 +47,7 @@ struct lock_info {
#define LIMIT_COUNT 128
-static Eina_List *lock_info_list;
+static dd_list *lock_info_list;
static long get_time(void)
{
@@ -59,18 +58,18 @@ static long get_time(void)
static void shrink_lock_info_list(void)
{
- Eina_List *l, *l_prev;
+ dd_list *l, *l_prev;
struct lock_info *info;
unsigned int count;
- count = eina_list_count(lock_info_list);
+ count = DD_LIST_LENGTH(lock_info_list);
if (count <= LIMIT_COUNT)
return;
_D("list is shrink : count %d", count);
- EINA_LIST_REVERSE_FOREACH_SAFE(lock_info_list, l, l_prev, info) {
+ DD_LIST_REVERSE_FOREACH_SAFE(lock_info_list, l, l_prev, info) {
if (info->locktime == 0) {
- EINA_LIST_REMOVE_LIST(lock_info_list, l);
+ DD_LIST_REMOVE_LIST(lock_info_list, l);
if (info->name)
free(info->name);
free(info);
@@ -84,7 +83,7 @@ static void shrink_lock_info_list(void)
int set_lock_time(const char *pname, int state)
{
struct lock_info *info;
- Eina_List *l;
+ dd_list *l;
unsigned long val;
if (!pname)
@@ -93,16 +92,18 @@ int set_lock_time(const char *pname, int state)
if (state < S_NORMAL || state > S_SLEEP)
return -EINVAL;
- val = eina_hash_superfast(pname, strlen(pname));
+ val = g_str_hash(pname);
- EINA_LIST_FOREACH(lock_info_list, l, info)
- if (info->hash == val && info->state == state) {
+ DD_LIST_FOREACH(lock_info_list, l, info)
+ if (info->hash == val &&
+ !strncmp(info->name, pname, strlen(pname)+1) &&
+ info->state == state) {
info->count += 1;
if (info->locktime == 0)
info->locktime = get_time();
info->unlocktime = 0;
- EINA_LIST_PROMOTE_LIST(lock_info_list, l);
- eina_list_data_set(l, info);
+ DD_LIST_REMOVE(lock_info_list, info);
+ DD_LIST_PREPEND(lock_info_list, info);
return 0;
}
@@ -120,7 +121,7 @@ int set_lock_time(const char *pname, int state)
info->unlocktime = 0;
info->time = 0;
- EINA_LIST_APPEND(lock_info_list, info);
+ DD_LIST_APPEND(lock_info_list, info);
return 0;
}
@@ -130,7 +131,7 @@ int set_unlock_time(const char *pname, int state)
bool find = false;
long diff;
struct lock_info *info;
- Eina_List *l;
+ dd_list *l;
unsigned long val;
if (!pname)
@@ -139,11 +140,14 @@ int set_unlock_time(const char *pname, int state)
if (state < S_NORMAL || state > S_SLEEP)
return -EINVAL;
- val = eina_hash_superfast(pname, strlen(pname));
+ val = g_str_hash(pname);
- EINA_LIST_FOREACH(lock_info_list, l, info)
- if (info->hash == val && info->state == state) {
- EINA_LIST_PROMOTE_LIST(lock_info_list, l);
+ DD_LIST_FOREACH(lock_info_list, l, info)
+ if (info->hash == val &&
+ !strncmp(info->name, pname, strlen(pname)+1) &&
+ info->state == state) {
+ DD_LIST_REMOVE(lock_info_list, info);
+ DD_LIST_PREPEND(lock_info_list, info);
find = true;
break;
}
@@ -161,9 +165,7 @@ int set_unlock_time(const char *pname, int state)
info->time += diff;
info->locktime = 0;
- eina_list_data_set(l, info);
-
- if (eina_list_count(lock_info_list) > LIMIT_COUNT)
+ if (DD_LIST_LENGTH(lock_info_list) > LIMIT_COUNT)
shrink_lock_info_list();
return 0;
@@ -171,14 +173,14 @@ int set_unlock_time(const char *pname, int state)
void free_lock_info_list(void)
{
- Eina_List *l, *l_next;
+ dd_list *l, *l_next;
struct lock_info *info;
if (!lock_info_list)
return;
- EINA_LIST_FOREACH_SAFE(lock_info_list, l, l_next, info) {
- EINA_LIST_REMOVE(lock_info_list, l);
+ DD_LIST_FOREACH_SAFE(lock_info_list, l, l_next, info) {
+ DD_LIST_REMOVE(lock_info_list, info);
if (info->name)
free(info->name);
free(info);
@@ -189,7 +191,7 @@ void free_lock_info_list(void)
void print_lock_info_list(int fd)
{
struct lock_info *info;
- Eina_List *l;
+ dd_list *l;
char buf[255];
if (!lock_info_list)
@@ -204,7 +206,7 @@ void print_lock_info_list(int fd)
"count", "locktime", "unlocktime", "time", "process name");
write(fd, buf, strlen(buf));
- EINA_LIST_FOREACH(lock_info_list, l, info) {
+ DD_LIST_FOREACH(lock_info_list, l, info) {
long time = 0;
if (info->locktime != 0 && info->unlocktime == 0)
time = get_time() - info->locktime;
diff --git a/src/shared/list.h b/src/shared/list.h
deleted file mode 100644
index b05e35f9..00000000
--- a/src/shared/list.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __LIST_H__
-#define __LIST_H__
-
-#include <glib.h>
-
-#define LIST_ADD(head, data) \
- do { \
- head = g_list_append(head, data); \
- } while(0)
-
-#define LIST_DEL(head, data) \
- do { \
- head = g_list_remove(head, data); \
- } while(0)
-
-#define LIST_FIND(head, node, t, name, data) \
- do { \
- t *tmp; \
- GList *elem; \
- for (elem = head; elem; elem = elem->next) { \
- tmp = elem->data; \
- if (tmp->##name != data) \
- continue; \
- node = tmp; \
- } \
- } while(0)
-
-#define LIST_FOREACH(head, item) \
- for (item = head; item; item = item->next)
-
-#endif