diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2011-10-31 13:19:09 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-11-10 13:09:50 +0100 |
commit | 9232d39e6a0738b750e97efd04124c81b7b2e583 (patch) | |
tree | 23b4bc3d39f0c6b16a55e8bc9df760e220f2c749 /src/device.c | |
parent | 6bd851d905799dfb02e66eadc37c2e85b4b8f402 (diff) | |
download | connman-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.c | 6 |
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) { |