diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2011-10-31 13:19:11 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-11-10 13:09:50 +0100 |
commit | 1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0 (patch) | |
tree | aa09d78b57d60b0829b1c017e2c58c9317d6d084 /gweb/gweb.c | |
parent | 7042430b16001cdc85912aea5fcf64d255fcb5b3 (diff) | |
download | connman-1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0.tar.gz connman-1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0.tar.bz2 connman-1b45ea1b9fb70daa4b4a2905ebd9d12b9c7140d0.zip |
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/gweb.c')
-rw-r--r-- | gweb/gweb.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c index b7cfe62e..5c3305ef 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); |