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.
} ClientState;
struct _GDHCPClient {
- gint ref_count;
+ int ref_count;
GDHCPType type;
ClientState state;
int ifindex;
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;
}
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);
#define OFFER_TIME (5*60)
struct _GDHCPServer {
- gint ref_count;
+ int ref_count;
GDHCPType type;
gboolean started;
int ifindex;
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;
}
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);