From 9fc06f5dd3fab51503f1ccbb2648ac9f09f0cbac Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 31 Oct 2011 13:19:12 +0100 Subject: 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. --- gdhcp/client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gdhcp/client.c') 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); -- cgit v1.2.3