[glib: 9/10] gthread: Use atomic pointer exchange to check value set on g_init_leave
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 9/10] gthread: Use atomic pointer exchange to check value set on g_init_leave
- Date: Sat, 23 Jul 2022 11:35:14 +0000 (UTC)
commit 00f3f0d407da0cdfceed3342a51147e725ab3cf7
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Tue Jun 21 05:02:30 2022 +0200
gthread: Use atomic pointer exchange to check value set on g_init_leave
glib/gthread.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/glib/gthread.c b/glib/gthread.c
index 0b03e64082..bc9b1c2b37 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -741,11 +741,13 @@ void
gsize result)
{
gsize *value_location = (gsize *) location;
+ gsize old_value;
- g_return_if_fail (g_atomic_pointer_get (value_location) == 0);
g_return_if_fail (result != 0);
- g_atomic_pointer_set (value_location, result);
+ old_value = (gsize) g_atomic_pointer_exchange (value_location, result);
+ g_return_if_fail (old_value == 0);
+
g_mutex_lock (&g_once_mutex);
g_return_if_fail (g_once_init_list != NULL);
g_once_init_list = g_slist_remove (g_once_init_list, (void*) value_location);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]