From 9232d39e6a0738b750e97efd04124c81b7b2e583 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 31 Oct 2011 13:19:09 +0100 Subject: 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. --- src/device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/device.c') 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) { -- cgit v1.2.3