summaryrefslogtreecommitdiff
path: root/src/device.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/device.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/device.c')
-rw-r--r--src/device.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/device.c b/src/device.c
index 9ba7caf7..29da1a13 100644
--- a/src/device.c
+++ b/src/device.c
@@ -39,7 +39,7 @@ enum connman_pending_type {
};
struct connman_device {
- gint refcount;
+ int refcount;
enum connman_device_type type;
enum connman_pending_type powered_pending; /* Indicates a pending
enable/disable request */
@@ -536,7 +536,7 @@ struct connman_device *connman_device_ref(struct connman_device *device)
{
DBG("%p", device);
- g_atomic_int_inc(&device->refcount);
+ __sync_fetch_and_add(&device->refcount, 1);
return device;
}
@@ -549,7 +549,7 @@ struct connman_device *connman_device_ref(struct connman_device *device)
*/
void connman_device_unref(struct connman_device *device)
{
- if (g_atomic_int_dec_and_test(&device->refcount) == FALSE)
+ if (__sync_fetch_and_sub(&device->refcount, 1) != 1)
return;
if (device->driver) {