summaryrefslogtreecommitdiff
path: root/plugins/tist.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-10-31 13:19:10 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2011-11-10 13:09:50 +0100
commit7042430b16001cdc85912aea5fcf64d255fcb5b3 (patch)
treeda9eb1138f319470836fee0ae600f320b35d21fc /plugins/tist.c
parent9232d39e6a0738b750e97efd04124c81b7b2e583 (diff)
downloadconnman-7042430b16001cdc85912aea5fcf64d255fcb5b3.tar.gz
connman-7042430b16001cdc85912aea5fcf64d255fcb5b3.tar.bz2
connman-7042430b16001cdc85912aea5fcf64d255fcb5b3.zip
plugins: 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 'plugins/tist.c')
-rw-r--r--plugins/tist.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/plugins/tist.c b/plugins/tist.c
index 9be38412..8a30d8fb 100644
--- a/plugins/tist.c
+++ b/plugins/tist.c
@@ -56,7 +56,7 @@ static unsigned long baud_rate = 0;
static guint install_watch = 0;
static guint uart_watch = 0;
-static gint install_count = 0;
+static int install_count = 0;
#define NCCS2 19
struct termios2 {
@@ -327,12 +327,15 @@ static gboolean uart_event(GIOChannel *channel,
if (ioctl(uart_fd, TIOCSETD, &ldisc) < 0)
goto err;
- g_atomic_int_set(&install_count, 0);
+ install_count = 1;
+ __sync_synchronize();
return FALSE;
err:
- g_atomic_int_set(&install_count, 0);
+ install_count = 0;
+ __sync_synchronize();
+
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
@@ -348,7 +351,8 @@ static int install_ldisc(GIOChannel *channel, gboolean install)
DBG("%d %p", install, uart_channel);
if (install == FALSE) {
- g_atomic_int_set(&install_count, 0);
+ install_count = 0;
+ __sync_synchronize();
if (uart_channel == NULL) {
DBG("UART channel is NULL");
@@ -404,7 +408,8 @@ static int install_ldisc(GIOChannel *channel, gboolean install)
uart_channel = NULL;
}
- g_atomic_int_set(&install_count, 0);
+ install_count = 0;
+ __sync_synchronize();
return 0;
}
@@ -447,7 +452,8 @@ static gboolean install_event(GIOChannel *channel,
return FALSE;
}
- if (g_atomic_int_get(&install_count) != 0) {
+ __sync_synchronize();
+ if (install_count != 0) {
status = g_io_channel_seek_position(channel, 0, G_SEEK_SET, NULL);
if (status != G_IO_STATUS_NORMAL) {
g_io_channel_shutdown(channel, TRUE, NULL);
@@ -468,7 +474,8 @@ static gboolean install_event(GIOChannel *channel,
return TRUE;
} else {
- g_atomic_int_set(&install_count, 1);
+ install_count = 1;
+ __sync_synchronize();
}
status = g_io_channel_seek_position(channel, 0, G_SEEK_SET, NULL);
@@ -494,7 +501,8 @@ static gboolean install_event(GIOChannel *channel,
if (install_ldisc(channel, install) < 0) {
connman_error("ldisc installation failed");
- g_atomic_int_set(&install_count, 0);
+ install_count = 0;
+ __sync_synchronize();
return TRUE;
}
@@ -564,7 +572,9 @@ static int tist_init(void)
install_event, NULL, NULL);
if (install_state) {
- g_atomic_int_set(&install_count, 1);
+ install_count = 1;
+ __sync_synchronize();
+
err = install_ldisc(install_channel, TRUE);
if (err < 0) {
connman_error("ldisc installtion failed");