summaryrefslogtreecommitdiff
path: root/gweb
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-10-31 12:19:11 (GMT)
committerSamuel Ortiz <sameo@linux.intel.com>2011-11-10 12:09:50 (GMT)
commit1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0 (patch)
treeaa09d78b57d60b0829b1c017e2c58c9317d6d084 /gweb
parent7042430b16001cdc85912aea5fcf64d255fcb5b3 (diff)
downloadconnman-1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0.zip
connman-1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0.tar.gz
connman-1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0.tar.bz2
gweb: 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 'gweb')
-rw-r--r--gweb/giognutls.c4
-rw-r--r--gweb/gresolv.c6
-rw-r--r--gweb/gweb.c10
3 files changed, 10 insertions, 10 deletions
diff --git a/gweb/giognutls.c b/gweb/giognutls.c
index a9b734f..d92ae95 100644
--- a/gweb/giognutls.c
+++ b/gweb/giognutls.c
@@ -54,11 +54,11 @@ struct _GIOGnuTLSWatch {
GIOCondition condition;
};
-static volatile gint global_init_done = 0;
+static volatile int global_init_done = 0;
static inline void g_io_gnutls_global_init(void)
{
- if (g_atomic_int_compare_and_exchange(&global_init_done, 0, 1) == TRUE)
+ if (__sync_bool_compare_and_swap(&global_init_done, 0, 1) == TRUE)
gnutls_global_init();
}
diff --git a/gweb/gresolv.c b/gweb/gresolv.c
index 326b5f9..6bfc20a 100644
--- a/gweb/gresolv.c
+++ b/gweb/gresolv.c
@@ -97,7 +97,7 @@ struct resolv_nameserver {
};
struct _GResolv {
- gint ref_count;
+ int ref_count;
int result_family;
@@ -826,7 +826,7 @@ GResolv *g_resolv_ref(GResolv *resolv)
if (resolv == NULL)
return NULL;
- g_atomic_int_inc(&resolv->ref_count);
+ __sync_fetch_and_add(&resolv->ref_count, 1);
return resolv;
}
@@ -838,7 +838,7 @@ void g_resolv_unref(GResolv *resolv)
if (resolv == NULL)
return;
- if (g_atomic_int_dec_and_test(&resolv->ref_count) == FALSE)
+ if (__sync_fetch_and_sub(&resolv->ref_count, 1) != 1)
return;
while ((query = g_queue_pop_head(resolv->query_queue)))
diff --git a/gweb/gweb.c b/gweb/gweb.c
index b7cfe62..5c3305e 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -97,7 +97,7 @@ struct web_session {
};
struct _GWeb {
- gint ref_count;
+ int ref_count;
guint next_query_id;
@@ -228,7 +228,7 @@ GWeb *g_web_ref(GWeb *web)
if (web == NULL)
return NULL;
- g_atomic_int_inc(&web->ref_count);
+ __sync_fetch_and_add(&web->ref_count, 1);
return web;
}
@@ -238,7 +238,7 @@ void g_web_unref(GWeb *web)
if (web == NULL)
return;
- if (g_atomic_int_dec_and_test(&web->ref_count) == FALSE)
+ if (__sync_fetch_and_sub(&web->ref_count, 1) != 1)
return;
flush_sessions(web);
@@ -1316,7 +1316,7 @@ GWebParser *g_web_parser_ref(GWebParser *parser)
if (parser == NULL)
return NULL;
- g_atomic_int_inc(&parser->ref_count);
+ __sync_fetch_and_add(&parser->ref_count, 1);
return parser;
}
@@ -1326,7 +1326,7 @@ void g_web_parser_unref(GWebParser *parser)
if (parser == NULL)
return;
- if (g_atomic_int_dec_and_test(&parser->ref_count) == FALSE)
+ if (__sync_fetch_and_sub(&parser->ref_count, 1) != 1)
return;
g_string_free(parser->content, TRUE);