[glib: 1/2] gatomicrefcount: Make g_atomic_ref_count_init non-atomic
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gatomicrefcount: Make g_atomic_ref_count_init non-atomic
- Date: Sun, 25 Nov 2018 00:53:14 +0000 (UTC)
commit 4fde2b273d4e85519f40b9c39b75fddb51465754
Author: Tomasz Miąsko <tomasz miasko gmail com>
Date: Tue Nov 6 00:00:00 2018 +0000
gatomicrefcount: Make g_atomic_ref_count_init non-atomic
Programmer needs to ensure that initializations happens before other
operations on gatomicrefcount as otherwise they could access
uninitialized memory, so there is no practical use case for making
initialization atomic.
glib/grefcount.c | 4 ++--
glib/grefcount.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/glib/grefcount.c b/glib/grefcount.c
index 37085316b..7cb12fc46 100644
--- a/glib/grefcount.c
+++ b/glib/grefcount.c
@@ -199,7 +199,7 @@ gboolean
* g_atomic_ref_count_init:
* @arc: the address of an atomic reference count variable
*
- * Atomically initializes a reference count variable.
+ * Initializes a reference count variable.
*
* Since: 2.58
*/
@@ -217,7 +217,7 @@ void
* Acquiring a reference moves us towards MAXINT, and releasing a
* reference moves us towards 0.
*/
- g_atomic_int_set (arc, 1);
+ *arc = 1;
}
/**
diff --git a/glib/grefcount.h b/glib/grefcount.h
index b6eced1b7..599dac978 100644
--- a/glib/grefcount.h
+++ b/glib/grefcount.h
@@ -92,7 +92,7 @@ gboolean g_atomic_ref_count_compare (gatomicrefcount *arc,
(G_GNUC_EXTENSION ({ \
G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \
(void) (0 ? *(rc) ^ *(rc) : 1); \
- g_atomic_int_set ((rc), 1); \
+ *(rc) = 1; \
}))
# define g_atomic_ref_count_inc(rc) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]