summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glib-2.0/glib-2.0/0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2021-03-04 11:38:40 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-03-14 16:33:59 +0000
commiteec64066073428e38d5b0b6947ff302943188f65 (patch)
treeec55d656734941dee8b2a599b588a12cc174337d /meta/recipes-core/glib-2.0/glib-2.0/0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch
parent8a74a7deca45ceef351f47a9f160df9bafc0f546 (diff)
downloadpoky-eec64066073428e38d5b0b6947ff302943188f65.tar.gz
glib-2.0: Drop volatile qualifier
Fixes glib/gatomic.h:112:5: error: argument 2 of '__atomic_load' discards 'volatile' qualifier [-Werror=incompatible-pointer-types] (From OE-Core rev: 06ac55a06f2300fa5442ec73a28c3f52022cc640) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/glib-2.0/glib-2.0/0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch')
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch b/meta/recipes-core/glib-2.0/glib-2.0/0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch
new file mode 100644
index 0000000000..c15a3b8a57
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch
@@ -0,0 +1,77 @@
1From 6bd0a4b29753570a2c20b61b5ad2c0068567b7b6 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Mon, 16 Nov 2020 16:44:29 +0000
4Subject: [PATCH 25/29] gthread: Use g_atomic() primitives correctly in
5 destructor list
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10In the Windows destructor list, consistently access
11`g_private_destructors` using atomic primitives.
12
13`g_atomic_pointer_compare_and_exchange()` should be equivalent to
14`InterlockedCompareExchangePointer()`, but is a bit more understandable
15in a general GLib context, and pairs with `g_atomic_pointer_get()`. (I
16can’t find a Windows API equivalent for that.)
17
18Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
19
20Helps: #600
21Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
22---
23 glib/gthread-win32.c | 13 +++++++------
24 1 file changed, 7 insertions(+), 6 deletions(-)
25
26diff --git a/glib/gthread-win32.c b/glib/gthread-win32.c
27index 0c37dc6c1..20aca6fa1 100644
28--- a/glib/gthread-win32.c
29+++ b/glib/gthread-win32.c
30@@ -301,7 +301,7 @@ struct _GPrivateDestructor
31 GPrivateDestructor *next;
32 };
33
34-static GPrivateDestructor * volatile g_private_destructors;
35+static GPrivateDestructor *g_private_destructors; /* (atomic) prepend-only */
36 static CRITICAL_SECTION g_private_lock;
37
38 static DWORD
39@@ -329,7 +329,7 @@ g_private_get_impl (GPrivate *key)
40 g_thread_abort (errno, "malloc");
41 destructor->index = impl;
42 destructor->notify = key->notify;
43- destructor->next = g_private_destructors;
44+ destructor->next = g_atomic_pointer_get (&g_private_destructors);
45
46 /* We need to do an atomic store due to the unlocked
47 * access to the destructor list from the thread exit
48@@ -337,13 +337,14 @@ g_private_get_impl (GPrivate *key)
49 *
50 * It can double as a sanity check...
51 */
52- if (InterlockedCompareExchangePointer (&g_private_destructors, destructor,
53- destructor->next) != destructor->next)
54+ if (!g_atomic_pointer_compare_and_exchange (&g_private_destructors,
55+ destructor->next,
56+ destructor))
57 g_thread_abort (0, "g_private_get_impl(1)");
58 }
59
60 /* Ditto, due to the unlocked access on the fast path */
61- if (InterlockedCompareExchangePointer (&key->p, impl, NULL) != NULL)
62+ if (!g_atomic_pointer_compare_and_exchange (&key->p, NULL, impl))
63 g_thread_abort (0, "g_private_get_impl(2)");
64 }
65 LeaveCriticalSection (&g_private_lock);
66@@ -635,7 +636,7 @@ g_thread_win32_thread_detach (void)
67 */
68 dtors_called = FALSE;
69
70- for (dtor = g_private_destructors; dtor; dtor = dtor->next)
71+ for (dtor = g_atomic_pointer_get (&g_private_destructors); dtor; dtor = dtor->next)
72 {
73 gpointer value;
74
75--
762.30.1
77