summaryrefslogtreecommitdiff
path: root/src/task.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-10-31 13:19:09 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2011-11-10 13:09:50 +0100
commit9232d39e6a0738b750e97efd04124c81b7b2e583 (patch)
tree23b4bc3d39f0c6b16a55e8bc9df760e220f2c749 /src/task.c
parent6bd851d905799dfb02e66eadc37c2e85b4b8f402 (diff)
downloadconnman-9232d39e6a0738b750e97efd04124c81b7b2e583.tar.gz
connman-9232d39e6a0738b750e97efd04124c81b7b2e583.tar.bz2
connman-9232d39e6a0738b750e97efd04124c81b7b2e583.zip
core: Use gcc atomics instead glib's ones
g_atomic_int_exchange_and_add() has been removed from glib 2.30 and g_atomic_int_add() should be used. Though there are still quite a few distros out which do not ship a glib version with g_atomic_int_add(). Instead of maintaing a compatiblilty glib layer we just use the built-in functions for atomic memory access.
Diffstat (limited to 'src/task.c')
-rw-r--r--src/task.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/task.c b/src/task.c
index 2fd2567a..41710cdc 100644
--- a/src/task.c
+++ b/src/task.c
@@ -51,7 +51,7 @@ struct connman_task {
static GHashTable *task_hash = NULL;
-static volatile gint task_counter;
+static volatile int task_counter;
static DBusConnection *connection;
@@ -105,7 +105,7 @@ struct connman_task *connman_task_create(const char *program)
if (task == NULL)
return NULL;
- counter = g_atomic_int_exchange_and_add(&task_counter, 1);
+ counter = __sync_fetch_and_add(&task_counter, 1);
task->path = g_strdup_printf("/task/%d", counter);
task->pid = -1;
@@ -425,7 +425,8 @@ int __connman_task_init(void)
dbus_connection_add_filter(connection, task_filter, NULL, NULL);
- g_atomic_int_set(&task_counter, 0);
+ task_counter = 0;
+ __sync_synchronize();
task_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, free_task);