summaryrefslogtreecommitdiff
path: root/gdhcp/client.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-10-31 13:19:12 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2011-11-10 13:09:50 +0100
commit9fc06f5dd3fab51503f1ccbb2648ac9f09f0cbac (patch)
tree6c5aee9524a13a19055fc7a1a92239c6e30707b9 /gdhcp/client.c
parent1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0 (diff)
downloadconnman-9fc06f5dd3fab51503f1ccbb2648ac9f09f0cbac.tar.gz
connman-9fc06f5dd3fab51503f1ccbb2648ac9f09f0cbac.tar.bz2
connman-9fc06f5dd3fab51503f1ccbb2648ac9f09f0cbac.zip
gdhcp: 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 'gdhcp/client.c')
-rw-r--r--gdhcp/client.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index 24614c76..32703465 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -72,7 +72,7 @@ typedef enum _dhcp_client_state {
} ClientState;
struct _GDHCPClient {
- gint ref_count;
+ int ref_count;
GDHCPType type;
ClientState state;
int ifindex;
@@ -1506,7 +1506,7 @@ GDHCPClient *g_dhcp_client_ref(GDHCPClient *dhcp_client)
if (dhcp_client == NULL)
return NULL;
- g_atomic_int_inc(&dhcp_client->ref_count);
+ __sync_fetch_and_add(&dhcp_client->ref_count, 1);
return dhcp_client;
}
@@ -1516,7 +1516,7 @@ void g_dhcp_client_unref(GDHCPClient *dhcp_client)
if (dhcp_client == NULL)
return;
- if (g_atomic_int_dec_and_test(&dhcp_client->ref_count) == FALSE)
+ if (__sync_fetch_and_sub(&dhcp_client->ref_count, 1) != 1)
return;
g_dhcp_client_stop(dhcp_client);