diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2011-10-31 13:19:12 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-11-10 13:09:50 +0100 |
commit | 9fc06f5dd3fab51503f1ccbb2648ac9f09f0cbac (patch) | |
tree | 6c5aee9524a13a19055fc7a1a92239c6e30707b9 /gdhcp | |
parent | 1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0 (diff) | |
download | connman-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')
-rw-r--r-- | gdhcp/client.c | 6 | ||||
-rw-r--r-- | gdhcp/server.c | 6 |
2 files changed, 6 insertions, 6 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); diff --git a/gdhcp/server.c b/gdhcp/server.c index 54c068b7..4f0b5b76 100644 --- a/gdhcp/server.c +++ b/gdhcp/server.c @@ -49,7 +49,7 @@ #define OFFER_TIME (5*60) struct _GDHCPServer { - gint ref_count; + int ref_count; GDHCPType type; gboolean started; int ifindex; @@ -821,7 +821,7 @@ GDHCPServer *g_dhcp_server_ref(GDHCPServer *dhcp_server) if (dhcp_server == NULL) return NULL; - g_atomic_int_inc(&dhcp_server->ref_count); + __sync_fetch_and_add(&dhcp_server->ref_count, 1); return dhcp_server; } @@ -846,7 +846,7 @@ void g_dhcp_server_unref(GDHCPServer *dhcp_server) if (dhcp_server == NULL) return; - if (g_atomic_int_dec_and_test(&dhcp_server->ref_count) == FALSE) + if (__sync_fetch_and_sub(&dhcp_server->ref_count, 1) != 1) return; g_dhcp_server_stop(dhcp_server); |