summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0001-gobject-Drop-use-of-volatile-from-get_type-macros.patch403
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0002-tests-Fix-non-atomic-access-to-a-shared-variable.patch44
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0003-tests-Fix-non-atomic-access-to-a-shared-variable.patch90
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0004-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch93
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0005-tests-Fix-non-atomic-access-to-some-shared-variables.patch702
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0006-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch35
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0007-gdbusconnection-Drop-unnecessary-volatile-qualifiers.patch111
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0008-gdbuserror-Drop-unnecessary-volatile-qualifiers-from.patch95
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0009-gio-Drop-unnecessary-volatile-qualifiers-from-intern.patch207
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0010-kqueue-Fix-unlocked-access-to-shared-variable.patch51
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0011-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch126
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0012-tests-Fix-non-atomic-access-to-some-shared-variables.patch103
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0013-gatomic-Drop-unnecessary-volatile-qualifiers-from-in.patch180
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0014-gatomic-Drop-unnecessary-volatile-qualifiers-from-ma.patch56
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0015-glib-Drop-unnecessary-volatile-qualifiers-from-inter.patch169
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0016-gobject-Drop-unnecessary-volatile-qualifiers-from-in.patch126
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0017-gmessages-Drop-unnecessary-volatile-qualifiers-from-.patch44
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0018-gtypes-Drop-volatile-qualifier-from-gatomicrefcount.patch35
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0019-gatomicarray-Drop-volatile-qualifier-from-GAtomicArr.patch44
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0020-gobject-Drop-volatile-qualifier-from-GObject.ref_cou.patch33
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0021-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch51
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0022-build-Drop-unnecessary-volatile-qualifiers-from-conf.patch38
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0023-gdbusprivate-Avoid-a-warning-about-a-statement-with-.patch33
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0024-tests-Add-comment-to-volatile-atomic-tests.patch49
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch77
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0026-gtype-Fix-some-typos-in-comments.patch47
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0027-gtype-Add-some-missing-atomic-accesses-to-init_state.patch76
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0028-gresource-Fix-a-pointer-mismatch-with-an-atomic-load.patch29
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/0029-docs-Document-not-to-use-volatile-qualifiers.patch258
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0_2.66.7.bb32
30 files changed, 3436 insertions, 1 deletions
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0001-gobject-Drop-use-of-volatile-from-get_type-macros.patch b/meta/recipes-core/glib-2.0/glib-2.0/0001-gobject-Drop-use-of-volatile-from-get_type-macros.patch
new file mode 100644
index 0000000000..4852186520
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0001-gobject-Drop-use-of-volatile-from-get_type-macros.patch
@@ -0,0 +1,403 @@
1From fab561f8d05794329184cd81f9ab9d9d77dcc22a Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:12:22 +0000
4Subject: [PATCH 01/29] gobject: Drop use of volatile from get_type() macros
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9http://isvolatileusefulwiththreads.in/c/
10
11It’s possible that the variables here are only marked as volatile
12because they’re arguments to `g_once_*()`. Those arguments will be
13modified in a subsequent commit.
14
15Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
16
17Helps: #600
18Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
19---
20 docs/reference/gobject/glib-mkenums.xml | 8 ++---
21 docs/reference/gobject/tut_gtype.xml | 2 +-
22 gio/gioenumtypes.c.template | 8 ++---
23 gio/tests/gsettings.c | 4 +--
24 gobject/gbinding.c | 8 ++---
25 gobject/gboxed.c | 8 ++---
26 gobject/glib-enumtypes.c.template | 8 ++---
27 gobject/gsourceclosure.c | 2 +-
28 gobject/gtype.h | 48 ++++++++++++-------------
29 gobject/tests/signals.c | 16 ++++-----
30 10 files changed, 56 insertions(+), 56 deletions(-)
31
32diff --git a/docs/reference/gobject/glib-mkenums.xml b/docs/reference/gobject/glib-mkenums.xml
33index 2200328ed..ce250a3ff 100644
34--- a/docs/reference/gobject/glib-mkenums.xml
35+++ b/docs/reference/gobject/glib-mkenums.xml
36@@ -480,9 +480,9 @@ A C source template file will typically look like this:
37 GType
38 @enum_name@_get_type (void)
39 {
40- static volatile gsize g_@type@_type_id__volatile;
41+ static gsize static_g_@type@_type_id;
42
43- if (g_once_init_enter (&amp;g_define_type_id__volatile))
44+ if (g_once_init_enter (&amp;static_g_@type@_type_id))
45 {
46 static const G@Type@Value values[] = {
47 /*** END value-header ***/
48@@ -498,9 +498,9 @@ GType
49 GType g_@type@_type_id =
50 g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
51
52- g_once_init_leave (&amp;g_@type@_type_id__volatile, g_@type@_type_id);
53+ g_once_init_leave (&amp;static_g_@type@_type_id, g_@type@_type_id);
54 }
55- return g_@type@_type_id__volatile;
56+ return static_g_@type@_type_id;
57 }
58
59 /*** END value-tail ***/
60diff --git a/docs/reference/gobject/tut_gtype.xml b/docs/reference/gobject/tut_gtype.xml
61index 25e37dc48..ee042889d 100644
62--- a/docs/reference/gobject/tut_gtype.xml
63+++ b/docs/reference/gobject/tut_gtype.xml
64@@ -852,7 +852,7 @@ viewer_editable_default_init (ViewerEditableInterface *iface)
65 GType
66 viewer_editable_get_type (void)
67 {
68- static volatile gsize type_id = 0;
69+ static gsize type_id = 0;
70 if (g_once_init_enter (&amp;type_id)) {
71 const GTypeInfo info = {
72 sizeof (ViewerEditableInterface),
73diff --git a/gio/gioenumtypes.c.template b/gio/gioenumtypes.c.template
74index e9adc4a38..948a01201 100644
75--- a/gio/gioenumtypes.c.template
76+++ b/gio/gioenumtypes.c.template
77@@ -13,9 +13,9 @@
78 GType
79 @enum_name@_get_type (void)
80 {
81- static volatile gsize g_define_type_id__volatile = 0;
82+ static gsize static_g_define_type_id = 0;
83
84- if (g_once_init_enter (&g_define_type_id__volatile))
85+ if (g_once_init_enter (&static_g_define_type_id))
86 {
87 static const G@Type@Value values[] = {
88 /*** END value-header ***/
89@@ -29,10 +29,10 @@ GType
90 };
91 GType g_define_type_id =
92 g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
93- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
94+ g_once_init_leave (&static_g_define_type_id, g_define_type_id);
95 }
96
97- return g_define_type_id__volatile;
98+ return static_g_define_type_id;
99 }
100
101 /*** END value-tail ***/
102diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
103index 2f81ae6c3..179d0fd2f 100644
104--- a/gio/tests/gsettings.c
105+++ b/gio/tests/gsettings.c
106@@ -1060,7 +1060,7 @@ test_object_set_property (GObject *object,
107 static GType
108 test_enum_get_type (void)
109 {
110- static volatile gsize define_type_id = 0;
111+ static gsize define_type_id = 0;
112
113 if (g_once_init_enter (&define_type_id))
114 {
115@@ -1082,7 +1082,7 @@ test_enum_get_type (void)
116 static GType
117 test_flags_get_type (void)
118 {
119- static volatile gsize define_type_id = 0;
120+ static gsize define_type_id = 0;
121
122 if (g_once_init_enter (&define_type_id))
123 {
124diff --git a/gobject/gbinding.c b/gobject/gbinding.c
125index 78a883075..662d76b3c 100644
126--- a/gobject/gbinding.c
127+++ b/gobject/gbinding.c
128@@ -120,9 +120,9 @@
129 GType
130 g_binding_flags_get_type (void)
131 {
132- static volatile gsize g_define_type_id__volatile = 0;
133+ static gsize static_g_define_type_id = 0;
134
135- if (g_once_init_enter (&g_define_type_id__volatile))
136+ if (g_once_init_enter (&static_g_define_type_id))
137 {
138 static const GFlagsValue values[] = {
139 { G_BINDING_DEFAULT, "G_BINDING_DEFAULT", "default" },
140@@ -133,10 +133,10 @@ g_binding_flags_get_type (void)
141 };
142 GType g_define_type_id =
143 g_flags_register_static (g_intern_static_string ("GBindingFlags"), values);
144- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
145+ g_once_init_leave (&static_g_define_type_id, g_define_type_id);
146 }
147
148- return g_define_type_id__volatile;
149+ return static_g_define_type_id;
150 }
151
152 #define G_BINDING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_BINDING, GBindingClass))
153diff --git a/gobject/gboxed.c b/gobject/gboxed.c
154index 30ba4e775..194251383 100644
155--- a/gobject/gboxed.c
156+++ b/gobject/gboxed.c
157@@ -180,19 +180,19 @@ G_DEFINE_BOXED_TYPE (GOptionGroup, g_option_group, g_option_group_ref, g_option_
158 GType
159 g_strv_get_type (void)
160 {
161- static volatile gsize g_define_type_id__volatile = 0;
162+ static gsize static_g_define_type_id = 0;
163
164- if (g_once_init_enter (&g_define_type_id__volatile))
165+ if (g_once_init_enter (&static_g_define_type_id))
166 {
167 GType g_define_type_id =
168 g_boxed_type_register_static (g_intern_static_string ("GStrv"),
169 (GBoxedCopyFunc) g_strdupv,
170 (GBoxedFreeFunc) g_strfreev);
171
172- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
173+ g_once_init_leave (&static_g_define_type_id, g_define_type_id);
174 }
175
176- return g_define_type_id__volatile;
177+ return static_g_define_type_id;
178 }
179
180 GType
181diff --git a/gobject/glib-enumtypes.c.template b/gobject/glib-enumtypes.c.template
182index b7d36728f..1800ca8af 100644
183--- a/gobject/glib-enumtypes.c.template
184+++ b/gobject/glib-enumtypes.c.template
185@@ -13,9 +13,9 @@
186 GType
187 @enum_name@_get_type (void)
188 {
189- static volatile gsize g_define_type_id__volatile = 0;
190+ static gsize static_g_define_type_id = 0;
191
192- if (g_once_init_enter (&g_define_type_id__volatile))
193+ if (g_once_init_enter (&static_g_define_type_id))
194 {
195 static const G@Type@Value values[] = {
196 /*** END value-header ***/
197@@ -29,10 +29,10 @@ GType
198 };
199 GType g_define_type_id =
200 g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
201- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
202+ g_once_init_leave (&static_g_define_type_id, g_define_type_id);
203 }
204
205- return g_define_type_id__volatile;
206+ return static_g_define_type_id;
207 }
208
209 /*** END value-tail ***/
210diff --git a/gobject/gsourceclosure.c b/gobject/gsourceclosure.c
211index 0d0d2e87c..d1b1ee4b3 100644
212--- a/gobject/gsourceclosure.c
213+++ b/gobject/gsourceclosure.c
214@@ -32,7 +32,7 @@ G_DEFINE_BOXED_TYPE (GIOChannel, g_io_channel, g_io_channel_ref, g_io_channel_un
215 GType
216 g_io_condition_get_type (void)
217 {
218- static volatile GType etype = 0;
219+ static GType etype = 0;
220
221 if (g_once_init_enter (&etype))
222 {
223diff --git a/gobject/gtype.h b/gobject/gtype.h
224index 9de46ac60..666fadb0c 100644
225--- a/gobject/gtype.h
226+++ b/gobject/gtype.h
227@@ -1727,8 +1727,8 @@ guint g_type_get_type_registration_serial (void);
228 * GType
229 * gtk_gadget_get_type (void)
230 * {
231- * static volatile gsize g_define_type_id__volatile = 0;
232- * if (g_once_init_enter (&g_define_type_id__volatile))
233+ * static gsize static_g_define_type_id = 0;
234+ * if (g_once_init_enter (&static_g_define_type_id))
235 * {
236 * GType g_define_type_id =
237 * g_type_register_static_simple (GTK_TYPE_WIDGET,
238@@ -1748,9 +1748,9 @@ guint g_type_get_type_registration_serial (void);
239 * };
240 * g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
241 * }
242- * g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
243+ * g_once_init_leave (&static_g_define_type_id, g_define_type_id);
244 * }
245- * return g_define_type_id__volatile;
246+ * return static_g_define_type_id;
247 * }
248 * ]|
249 * The only pieces which have to be manually provided are the definitions of
250@@ -1995,17 +1995,17 @@ type_name##_get_instance_private (TypeName *self) \
251 GType \
252 type_name##_get_type (void) \
253 { \
254- static volatile gsize g_define_type_id__volatile = 0;
255+ static gsize static_g_define_type_id = 0;
256 /* Prelude goes here */
257
258 /* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */
259 #define _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
260- if (g_once_init_enter (&g_define_type_id__volatile)) \
261+ if (g_once_init_enter (&static_g_define_type_id)) \
262 { \
263 GType g_define_type_id = type_name##_get_type_once (); \
264- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
265+ g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
266 } \
267- return g_define_type_id__volatile; \
268+ return static_g_define_type_id; \
269 } /* closes type_name##_get_type() */ \
270 \
271 G_GNUC_NO_INLINE \
272@@ -2041,8 +2041,8 @@ static void type_name##_default_init (TypeName##Interface *klass); \
273 GType \
274 type_name##_get_type (void) \
275 { \
276- static volatile gsize g_define_type_id__volatile = 0; \
277- if (g_once_init_enter (&g_define_type_id__volatile)) \
278+ static gsize static_g_define_type_id = 0; \
279+ if (g_once_init_enter (&static_g_define_type_id)) \
280 { \
281 GType g_define_type_id = \
282 g_type_register_static_simple (G_TYPE_INTERFACE, \
283@@ -2058,9 +2058,9 @@ type_name##_get_type (void) \
284 #define _G_DEFINE_INTERFACE_EXTENDED_END() \
285 /* following custom code */ \
286 } \
287- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
288+ g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
289 } \
290- return g_define_type_id__volatile; \
291+ return static_g_define_type_id; \
292 } /* closes type_name##_get_type() */
293
294 /**
295@@ -2115,13 +2115,13 @@ static GType type_name##_get_type_once (void); \
296 GType \
297 type_name##_get_type (void) \
298 { \
299- static volatile gsize g_define_type_id__volatile = 0; \
300- if (g_once_init_enter (&g_define_type_id__volatile)) \
301+ static gsize static_g_define_type_id = 0; \
302+ if (g_once_init_enter (&static_g_define_type_id)) \
303 { \
304 GType g_define_type_id = type_name##_get_type_once (); \
305- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
306+ g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
307 } \
308- return g_define_type_id__volatile; \
309+ return static_g_define_type_id; \
310 } \
311 \
312 G_GNUC_NO_INLINE \
313@@ -2152,13 +2152,13 @@ static GType type_name##_get_type_once (void); \
314 GType \
315 type_name##_get_type (void) \
316 { \
317- static volatile gsize g_define_type_id__volatile = 0; \
318- if (g_once_init_enter (&g_define_type_id__volatile)) \
319+ static gsize static_g_define_type_id = 0; \
320+ if (g_once_init_enter (&static_g_define_type_id)) \
321 { \
322 GType g_define_type_id = type_name##_get_type_once (); \
323- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
324+ g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
325 } \
326- return g_define_type_id__volatile; \
327+ return static_g_define_type_id; \
328 } \
329 \
330 G_GNUC_NO_INLINE \
331@@ -2205,13 +2205,13 @@ static GType type_name##_get_type_once (void); \
332 GType \
333 type_name##_get_type (void) \
334 { \
335- static volatile gsize g_define_type_id__volatile = 0; \
336- if (g_once_init_enter (&g_define_type_id__volatile)) \
337+ static gsize static_g_define_type_id = 0; \
338+ if (g_once_init_enter (&static_g_define_type_id)) \
339 { \
340 GType g_define_type_id = type_name##_get_type_once (); \
341- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
342+ g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
343 } \
344- return g_define_type_id__volatile; \
345+ return static_g_define_type_id; \
346 } \
347 \
348 G_GNUC_NO_INLINE \
349diff --git a/gobject/tests/signals.c b/gobject/tests/signals.c
350index 120f90b5c..ac0ce5102 100644
351--- a/gobject/tests/signals.c
352+++ b/gobject/tests/signals.c
353@@ -66,9 +66,9 @@ custom_marshal_VOID__INVOCATIONHINT (GClosure *closure,
354 static GType
355 test_enum_get_type (void)
356 {
357- static volatile gsize g_define_type_id__volatile = 0;
358+ static gsize static_g_define_type_id = 0;
359
360- if (g_once_init_enter (&g_define_type_id__volatile))
361+ if (g_once_init_enter (&static_g_define_type_id))
362 {
363 static const GEnumValue values[] = {
364 { TEST_ENUM_NEGATIVE, "TEST_ENUM_NEGATIVE", "negative" },
365@@ -79,18 +79,18 @@ test_enum_get_type (void)
366 };
367 GType g_define_type_id =
368 g_enum_register_static (g_intern_static_string ("TestEnum"), values);
369- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
370+ g_once_init_leave (&static_g_define_type_id, g_define_type_id);
371 }
372
373- return g_define_type_id__volatile;
374+ return static_g_define_type_id;
375 }
376
377 static GType
378 test_unsigned_enum_get_type (void)
379 {
380- static volatile gsize g_define_type_id__volatile = 0;
381+ static gsize static_g_define_type_id = 0;
382
383- if (g_once_init_enter (&g_define_type_id__volatile))
384+ if (g_once_init_enter (&static_g_define_type_id))
385 {
386 static const GEnumValue values[] = {
387 { TEST_UNSIGNED_ENUM_FOO, "TEST_UNSIGNED_ENUM_FOO", "foo" },
388@@ -99,10 +99,10 @@ test_unsigned_enum_get_type (void)
389 };
390 GType g_define_type_id =
391 g_enum_register_static (g_intern_static_string ("TestUnsignedEnum"), values);
392- g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
393+ g_once_init_leave (&static_g_define_type_id, g_define_type_id);
394 }
395
396- return g_define_type_id__volatile;
397+ return static_g_define_type_id;
398 }
399
400 typedef enum {
401--
4022.30.1
403
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0002-tests-Fix-non-atomic-access-to-a-shared-variable.patch b/meta/recipes-core/glib-2.0/glib-2.0/0002-tests-Fix-non-atomic-access-to-a-shared-variable.patch
new file mode 100644
index 0000000000..fada7cc38e
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0002-tests-Fix-non-atomic-access-to-a-shared-variable.patch
@@ -0,0 +1,44 @@
1From a6ce0e742a5c75c53a7c702ebb1af1084065160a Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:14:29 +0000
4Subject: [PATCH 02/29] tests: Fix non-atomic access to a shared variable
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9And drop the `volatile` qualifier from the variable, as that doesn’t
10help with thread safety.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 glib/tests/642026.c | 4 ++--
18 1 file changed, 2 insertions(+), 2 deletions(-)
19
20diff --git a/glib/tests/642026.c b/glib/tests/642026.c
21index ef54f14bb..26ab2ed06 100644
22--- a/glib/tests/642026.c
23+++ b/glib/tests/642026.c
24@@ -25,7 +25,7 @@ static GMutex *mutex;
25 static GCond *cond;
26 static guint i;
27
28-static volatile gint freed = 0;
29+static gint freed = 0; /* (atomic) */
30
31 static void
32 notify (gpointer p)
33@@ -63,7 +63,7 @@ testcase (void)
34 GThread *t1;
35
36 g_static_private_init (&sp);
37- freed = 0;
38+ g_atomic_int_set (&freed, 0);
39
40 t1 = g_thread_create (thread_func, NULL, TRUE, NULL);
41 g_assert (t1 != NULL);
42--
432.30.1
44
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0003-tests-Fix-non-atomic-access-to-a-shared-variable.patch b/meta/recipes-core/glib-2.0/glib-2.0/0003-tests-Fix-non-atomic-access-to-a-shared-variable.patch
new file mode 100644
index 0000000000..8bc71a698d
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0003-tests-Fix-non-atomic-access-to-a-shared-variable.patch
@@ -0,0 +1,90 @@
1From ea746c79faf554d980c21b0e4381753e003d2dc6 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:17:23 +0000
4Subject: [PATCH 03/29] tests: Fix non-atomic access to a shared variable
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9And drop the `volatile` qualifier from the variable, as that doesn’t
10help with thread safety.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 glib/tests/mainloop.c | 20 ++++++++++----------
18 1 file changed, 10 insertions(+), 10 deletions(-)
19
20diff --git a/glib/tests/mainloop.c b/glib/tests/mainloop.c
21index 16763a0ea..563a951de 100644
22--- a/glib/tests/mainloop.c
23+++ b/glib/tests/mainloop.c
24@@ -918,7 +918,7 @@ test_mainloop_overflow (void)
25 g_main_context_unref (ctx);
26 }
27
28-static volatile gint ready_time_dispatched;
29+static gint ready_time_dispatched; /* (atomic) */
30
31 static gboolean
32 ready_time_dispatch (GSource *source,
33@@ -964,7 +964,7 @@ test_ready_time (void)
34 /* A source with no ready time set should not fire */
35 g_assert_cmpint (g_source_get_ready_time (source), ==, -1);
36 while (g_main_context_iteration (NULL, FALSE));
37- g_assert_false (ready_time_dispatched);
38+ g_assert_false (g_atomic_int_get (&ready_time_dispatched));
39
40 /* The ready time should not have been changed */
41 g_assert_cmpint (g_source_get_ready_time (source), ==, -1);
42@@ -978,37 +978,37 @@ test_ready_time (void)
43 */
44 g_source_set_ready_time (source, g_get_monotonic_time () + G_TIME_SPAN_DAY);
45 while (g_main_context_iteration (NULL, FALSE));
46- g_assert_false (ready_time_dispatched);
47+ g_assert_false (g_atomic_int_get (&ready_time_dispatched));
48 /* Make sure it didn't get reset */
49 g_assert_cmpint (g_source_get_ready_time (source), !=, -1);
50
51 /* Ready time of -1 -> don't fire */
52 g_source_set_ready_time (source, -1);
53 while (g_main_context_iteration (NULL, FALSE));
54- g_assert_false (ready_time_dispatched);
55+ g_assert_false (g_atomic_int_get (&ready_time_dispatched));
56 /* Not reset, but should still be -1 from above */
57 g_assert_cmpint (g_source_get_ready_time (source), ==, -1);
58
59 /* A ready time of the current time should fire immediately */
60 g_source_set_ready_time (source, g_get_monotonic_time ());
61 while (g_main_context_iteration (NULL, FALSE));
62- g_assert_true (ready_time_dispatched);
63- ready_time_dispatched = FALSE;
64+ g_assert_true (g_atomic_int_get (&ready_time_dispatched));
65+ g_atomic_int_set (&ready_time_dispatched, FALSE);
66 /* Should have gotten reset by the handler function */
67 g_assert_cmpint (g_source_get_ready_time (source), ==, -1);
68
69 /* As well as one in the recent past... */
70 g_source_set_ready_time (source, g_get_monotonic_time () - G_TIME_SPAN_SECOND);
71 while (g_main_context_iteration (NULL, FALSE));
72- g_assert_true (ready_time_dispatched);
73- ready_time_dispatched = FALSE;
74+ g_assert_true (g_atomic_int_get (&ready_time_dispatched));
75+ g_atomic_int_set (&ready_time_dispatched, FALSE);
76 g_assert_cmpint (g_source_get_ready_time (source), ==, -1);
77
78 /* Zero is the 'official' way to get a source to fire immediately */
79 g_source_set_ready_time (source, 0);
80 while (g_main_context_iteration (NULL, FALSE));
81- g_assert_true (ready_time_dispatched);
82- ready_time_dispatched = FALSE;
83+ g_assert_true (g_atomic_int_get (&ready_time_dispatched));
84+ g_atomic_int_set (&ready_time_dispatched, FALSE);
85 g_assert_cmpint (g_source_get_ready_time (source), ==, -1);
86
87 /* Now do some tests of cross-thread wakeups.
88--
892.30.1
90
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0004-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch b/meta/recipes-core/glib-2.0/glib-2.0/0004-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
new file mode 100644
index 0000000000..4b7b6f463a
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0004-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
@@ -0,0 +1,93 @@
1From 3dda662bebb81666d009635df1055ba5c1e17b52 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:16:17 +0000
4Subject: [PATCH 04/29] tests: Drop unnecessary volatile qualifiers from tests
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9These variables were already (correctly) accessed atomically. The
10`volatile` qualifier doesn’t help with that.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 glib/tests/atomic.c | 4 ++--
18 glib/tests/cond.c | 2 +-
19 glib/tests/gwakeuptest.c | 2 +-
20 glib/tests/hash.c | 2 +-
21 glib/tests/slice.c | 2 +-
22 5 files changed, 6 insertions(+), 6 deletions(-)
23
24diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c
25index 6b6cc7f3e..7d2459f3a 100644
26--- a/glib/tests/atomic.c
27+++ b/glib/tests/atomic.c
28@@ -248,8 +248,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
29 #define THREADS 10
30 #define ROUNDS 10000
31
32-volatile gint bucket[THREADS];
33-volatile gint atomic;
34+gint bucket[THREADS]; /* never contested by threads, not accessed atomically */
35+gint atomic; /* (atomic) */
36
37 static gpointer
38 thread_func (gpointer data)
39diff --git a/glib/tests/cond.c b/glib/tests/cond.c
40index 0f0b3d249..ed338cce3 100644
41--- a/glib/tests/cond.c
42+++ b/glib/tests/cond.c
43@@ -29,7 +29,7 @@
44
45 static GCond cond;
46 static GMutex mutex;
47-static volatile gint next;
48+static gint next; /* locked by @mutex */
49
50 static void
51 push_value (gint value)
52diff --git a/glib/tests/gwakeuptest.c b/glib/tests/gwakeuptest.c
53index 461a7d3de..b37fb43fc 100644
54--- a/glib/tests/gwakeuptest.c
55+++ b/glib/tests/gwakeuptest.c
56@@ -92,7 +92,7 @@ struct context
57 static struct context contexts[NUM_THREADS];
58 static GThread *threads[NUM_THREADS];
59 static GWakeup *last_token_wakeup;
60-static volatile gint tokens_alive;
61+static gint tokens_alive; /* (atomic) */
62
63 static void
64 context_init (struct context *ctx)
65diff --git a/glib/tests/hash.c b/glib/tests/hash.c
66index 4623d18d1..f4ff55ce1 100644
67--- a/glib/tests/hash.c
68+++ b/glib/tests/hash.c
69@@ -1362,7 +1362,7 @@ struct _GHashTable
70
71 GHashFunc hash_func;
72 GEqualFunc key_equal_func;
73- volatile gint ref_count;
74+ gint ref_count; /* (atomic) */
75
76 #ifndef G_DISABLE_ASSERT
77 int version;
78diff --git a/glib/tests/slice.c b/glib/tests/slice.c
79index f37826f3a..a566280db 100644
80--- a/glib/tests/slice.c
81+++ b/glib/tests/slice.c
82@@ -107,7 +107,7 @@ thread_allocate (gpointer data)
83 gint b;
84 gint size;
85 gpointer p;
86- volatile gpointer *loc;
87+ gpointer *loc; /* (atomic) */
88
89 for (i = 0; i < 10000; i++)
90 {
91--
922.30.1
93
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0005-tests-Fix-non-atomic-access-to-some-shared-variables.patch b/meta/recipes-core/glib-2.0/glib-2.0/0005-tests-Fix-non-atomic-access-to-some-shared-variables.patch
new file mode 100644
index 0000000000..3aecf4582b
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0005-tests-Fix-non-atomic-access-to-some-shared-variables.patch
@@ -0,0 +1,702 @@
1From 7f905ff1faf0acbe0d2ce69937e031fcacce9294 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:21:00 +0000
4Subject: [PATCH 05/29] tests: Fix non-atomic access to some shared variables
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9And drop the `volatile` qualifier from the variables, as that doesn’t
10help with thread safety.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 gio/tests/gdbus-connection-flush.c | 6 +-
18 gio/tests/gdbus-connection.c | 40 ++++----
19 gio/tests/gdbus-overflow.c | 20 ++--
20 gio/tests/socket-service.c | 6 +-
21 gio/tests/task.c | 150 ++++++++++++++---------------
22 5 files changed, 111 insertions(+), 111 deletions(-)
23
24--- a/gio/tests/gdbus-connection-flush.c
25+++ b/gio/tests/gdbus-connection-flush.c
26@@ -43,9 +43,9 @@ G_LOCK_DEFINE_STATIC (write);
27 typedef struct {
28 GFilterOutputStream parent;
29
30- volatile gint started;
31- volatile gint finished;
32- volatile gint flushed;
33+ gint started; /* (atomic) */
34+ gint finished; /* (atomic) */
35+ gint flushed; /* (atomic) */
36
37 GOutputStream *real_output;
38 } MyOutputStream;
39--- a/gio/tests/gdbus-connection.c
40+++ b/gio/tests/gdbus-connection.c
41@@ -61,9 +61,9 @@ _log (const gchar *format, ...)
42 static gboolean
43 test_connection_quit_mainloop (gpointer user_data)
44 {
45- volatile gboolean *quit_mainloop_fired = user_data;
46+ gboolean *quit_mainloop_fired = user_data; /* (atomic) */
47 _log ("quit_mainloop_fired");
48- *quit_mainloop_fired = TRUE;
49+ g_atomic_int_set (quit_mainloop_fired, TRUE);
50 g_main_loop_quit (loop);
51 return TRUE;
52 }
53@@ -113,8 +113,8 @@ on_name_owner_changed (GDBusConnection *
54 static void
55 a_gdestroynotify_that_sets_a_gboolean_to_true_and_quits_loop (gpointer user_data)
56 {
57- volatile gboolean *val = user_data;
58- *val = TRUE;
59+ gboolean *val = user_data; /* (atomic) */
60+ g_atomic_int_set (val, TRUE);
61 _log ("destroynotify fired for %p", val);
62 g_main_loop_quit (loop);
63 }
64@@ -143,10 +143,10 @@ test_connection_life_cycle (void)
65 GDBusConnection *c;
66 GDBusConnection *c2;
67 GError *error;
68- volatile gboolean on_signal_registration_freed_called;
69- volatile gboolean on_filter_freed_called;
70- volatile gboolean on_register_object_freed_called;
71- volatile gboolean quit_mainloop_fired;
72+ gboolean on_signal_registration_freed_called; /* (atomic) */
73+ gboolean on_filter_freed_called; /* (atomic) */
74+ gboolean on_register_object_freed_called; /* (atomic) */
75+ gboolean quit_mainloop_fired; /* (atomic) */
76 guint quit_mainloop_id;
77 guint registration_id;
78
79@@ -208,7 +208,7 @@ test_connection_life_cycle (void)
80 g_assert_no_error (error);
81 g_assert_nonnull (c2);
82 /* signal registration */
83- on_signal_registration_freed_called = FALSE;
84+ g_atomic_int_set (&on_signal_registration_freed_called, FALSE);
85 g_dbus_connection_signal_subscribe (c2,
86 "org.freedesktop.DBus", /* bus name */
87 "org.freedesktop.DBus", /* interface */
88@@ -220,13 +220,13 @@ test_connection_life_cycle (void)
89 (gpointer) &on_signal_registration_freed_called,
90 a_gdestroynotify_that_sets_a_gboolean_to_true_and_quits_loop);
91 /* filter func */
92- on_filter_freed_called = FALSE;
93+ g_atomic_int_set (&on_filter_freed_called, FALSE);
94 g_dbus_connection_add_filter (c2,
95 some_filter_func,
96 (gpointer) &on_filter_freed_called,
97 a_gdestroynotify_that_sets_a_gboolean_to_true_and_quits_loop);
98 /* object registration */
99- on_register_object_freed_called = FALSE;
100+ g_atomic_int_set (&on_register_object_freed_called, FALSE);
101 error = NULL;
102 registration_id = g_dbus_connection_register_object (c2,
103 "/foo",
104@@ -239,7 +239,7 @@ test_connection_life_cycle (void)
105 g_assert_cmpuint (registration_id, >, 0);
106 /* ok, finalize the connection and check that all the GDestroyNotify functions are invoked as expected */
107 g_object_unref (c2);
108- quit_mainloop_fired = FALSE;
109+ g_atomic_int_set (&quit_mainloop_fired, FALSE);
110 quit_mainloop_id = g_timeout_add (30000, test_connection_quit_mainloop, (gpointer) &quit_mainloop_fired);
111 _log ("destroynotifies for\n"
112 " register_object %p\n"
113@@ -250,21 +250,21 @@ test_connection_life_cycle (void)
114 &on_signal_registration_freed_called);
115 while (TRUE)
116 {
117- if (on_signal_registration_freed_called &&
118- on_filter_freed_called &&
119- on_register_object_freed_called)
120+ if (g_atomic_int_get (&on_signal_registration_freed_called) &&
121+ g_atomic_int_get (&on_filter_freed_called) &&
122+ g_atomic_int_get (&on_register_object_freed_called))
123 break;
124- if (quit_mainloop_fired)
125+ if (g_atomic_int_get (&quit_mainloop_fired))
126 break;
127 _log ("entering loop");
128 g_main_loop_run (loop);
129 _log ("exiting loop");
130 }
131 g_source_remove (quit_mainloop_id);
132- g_assert_true (on_signal_registration_freed_called);
133- g_assert_true (on_filter_freed_called);
134- g_assert_true (on_register_object_freed_called);
135- g_assert_false (quit_mainloop_fired);
136+ g_assert_true (g_atomic_int_get (&on_signal_registration_freed_called));
137+ g_assert_true (g_atomic_int_get (&on_filter_freed_called));
138+ g_assert_true (g_atomic_int_get (&on_register_object_freed_called));
139+ g_assert_false (g_atomic_int_get (&quit_mainloop_fired));
140
141 /*
142 * Check for correct behavior when the bus goes away
143--- a/gio/tests/gdbus-overflow.c
144+++ b/gio/tests/gdbus-overflow.c
145@@ -86,8 +86,8 @@ overflow_filter_func (GDBusConnection *c
146 gboolean incoming,
147 gpointer user_data)
148 {
149- volatile gint *counter = user_data;
150- *counter += 1;
151+ gint *counter = user_data; /* (atomic) */
152+ g_atomic_int_inc (counter);
153 return message;
154 }
155
156@@ -108,8 +108,8 @@ test_overflow (void)
157 GDBusConnection *producer, *consumer;
158 GError *error;
159 GTimer *timer;
160- volatile gint n_messages_received;
161- volatile gint n_messages_sent;
162+ gint n_messages_received; /* (atomic) */
163+ gint n_messages_sent; /* (atomic) */
164
165 g_assert_cmpint (socketpair (AF_UNIX, SOCK_STREAM, 0, sv), ==, 0);
166
167@@ -129,7 +129,7 @@ test_overflow (void)
168 g_dbus_connection_set_exit_on_close (producer, TRUE);
169 g_assert_no_error (error);
170 g_object_unref (socket_connection);
171- n_messages_sent = 0;
172+ g_atomic_int_set (&n_messages_sent, 0);
173 g_dbus_connection_add_filter (producer, overflow_filter_func, (gpointer) &n_messages_sent, NULL);
174
175 /* send enough data that we get an EAGAIN */
176@@ -155,7 +155,7 @@ test_overflow (void)
177 */
178 g_timeout_add (500, overflow_on_500ms_later_func, NULL);
179 g_main_loop_run (loop);
180- g_assert_cmpint (n_messages_sent, <, OVERFLOW_NUM_SIGNALS);
181+ g_assert_cmpint (g_atomic_int_get (&n_messages_sent), <, OVERFLOW_NUM_SIGNALS);
182
183 /* now suck it all out as a client, and add it up */
184 socket = g_socket_new_from_fd (sv[1], &error);
185@@ -171,18 +171,18 @@ test_overflow (void)
186 &error);
187 g_assert_no_error (error);
188 g_object_unref (socket_connection);
189- n_messages_received = 0;
190+ g_atomic_int_set (&n_messages_received, 0);
191 g_dbus_connection_add_filter (consumer, overflow_filter_func, (gpointer) &n_messages_received, NULL);
192 g_dbus_connection_start_message_processing (consumer);
193
194 timer = g_timer_new ();
195 g_timer_start (timer);
196
197- while (n_messages_received < OVERFLOW_NUM_SIGNALS && g_timer_elapsed (timer, NULL) < OVERFLOW_TIMEOUT_SEC)
198+ while (g_atomic_int_get (&n_messages_received) < OVERFLOW_NUM_SIGNALS && g_timer_elapsed (timer, NULL) < OVERFLOW_TIMEOUT_SEC)
199 g_main_context_iteration (NULL, FALSE);
200
201- g_assert_cmpint (n_messages_sent, ==, OVERFLOW_NUM_SIGNALS);
202- g_assert_cmpint (n_messages_received, ==, OVERFLOW_NUM_SIGNALS);
203+ g_assert_cmpint (g_atomic_int_get (&n_messages_sent), ==, OVERFLOW_NUM_SIGNALS);
204+ g_assert_cmpint (g_atomic_int_get (&n_messages_received), ==, OVERFLOW_NUM_SIGNALS);
205
206 g_timer_destroy (timer);
207 g_object_unref (consumer);
208--- a/gio/tests/socket-service.c
209+++ b/gio/tests/socket-service.c
210@@ -99,7 +99,7 @@ test_start_stop (void)
211
212 GMutex mutex_712570;
213 GCond cond_712570;
214-volatile gboolean finalized;
215+gboolean finalized; /* (atomic) */
216
217 GType test_threaded_socket_service_get_type (void);
218 typedef GThreadedSocketService TestThreadedSocketService;
219@@ -120,7 +120,7 @@ test_threaded_socket_service_finalize (G
220 /* Signal the main thread that finalization completed successfully
221 * rather than hanging.
222 */
223- finalized = TRUE;
224+ g_atomic_int_set (&finalized, TRUE);
225 g_cond_signal (&cond_712570);
226 g_mutex_unlock (&mutex_712570);
227 }
228@@ -235,7 +235,7 @@ test_threaded_712570 (void)
229 */
230 g_object_unref (service);
231
232- while (!finalized)
233+ while (!g_atomic_int_get (&finalized))
234 g_cond_wait (&cond_712570, &mutex_712570);
235 g_mutex_unlock (&mutex_712570);
236 }
237--- a/gio/tests/task.c
238+++ b/gio/tests/task.c
239@@ -957,7 +957,7 @@ task_weak_notify (gpointer user_data,
240 gboolean *weak_notify_ran = user_data;
241
242 g_mutex_lock (&run_in_thread_mutex);
243- *weak_notify_ran = TRUE;
244+ g_atomic_int_set (weak_notify_ran, TRUE);
245 g_cond_signal (&run_in_thread_cond);
246 g_mutex_unlock (&run_in_thread_mutex);
247 }
248@@ -1007,7 +1007,7 @@ run_in_thread_thread (GTask *task
249 g_assert (g_thread_self () != main_thread);
250
251 g_mutex_lock (&run_in_thread_mutex);
252- *thread_ran = TRUE;
253+ g_atomic_int_set (thread_ran, TRUE);
254 g_cond_signal (&run_in_thread_cond);
255 g_mutex_unlock (&run_in_thread_mutex);
256
257@@ -1018,8 +1018,8 @@ static void
258 test_run_in_thread (void)
259 {
260 GTask *task;
261- volatile gboolean thread_ran = FALSE;
262- volatile gboolean weak_notify_ran = FALSE;
263+ gboolean thread_ran = FALSE; /* (atomic) */
264+ gboolean weak_notify_ran = FALSE; /* (atomic) */
265 gboolean notification_emitted = FALSE;
266 gboolean done = FALSE;
267
268@@ -1033,12 +1033,12 @@ test_run_in_thread (void)
269 g_task_run_in_thread (task, run_in_thread_thread);
270
271 g_mutex_lock (&run_in_thread_mutex);
272- while (!thread_ran)
273+ while (!g_atomic_int_get (&thread_ran))
274 g_cond_wait (&run_in_thread_cond, &run_in_thread_mutex);
275 g_mutex_unlock (&run_in_thread_mutex);
276
277 g_assert (done == FALSE);
278- g_assert (weak_notify_ran == FALSE);
279+ g_assert_false (g_atomic_int_get (&weak_notify_ran));
280
281 g_main_loop_run (loop);
282
283@@ -1050,7 +1050,7 @@ test_run_in_thread (void)
284 g_object_unref (task);
285
286 g_mutex_lock (&run_in_thread_mutex);
287- while (!weak_notify_ran)
288+ while (!g_atomic_int_get (&weak_notify_ran))
289 g_cond_wait (&run_in_thread_cond, &run_in_thread_mutex);
290 g_mutex_unlock (&run_in_thread_mutex);
291 }
292@@ -1081,7 +1081,7 @@ run_in_thread_sync_thread (GTask
293
294 g_assert (g_thread_self () != main_thread);
295
296- *thread_ran = TRUE;
297+ g_atomic_int_set (thread_ran, TRUE);
298 g_task_return_int (task, magic);
299 }
300
301@@ -1102,7 +1102,7 @@ test_run_in_thread_sync (void)
302 g_task_set_task_data (task, &thread_ran, NULL);
303 g_task_run_in_thread_sync (task, run_in_thread_sync_thread);
304
305- g_assert (thread_ran == TRUE);
306+ g_assert_true (g_atomic_int_get (&thread_ran));
307 g_assert (task != NULL);
308 g_assert (!g_task_had_error (task));
309 g_assert_true (g_task_get_completed (task));
310@@ -1487,8 +1487,8 @@ test_return_on_cancel (void)
311 {
312 GTask *task;
313 GCancellable *cancellable;
314- volatile ThreadState thread_state;
315- volatile gboolean weak_notify_ran = FALSE;
316+ ThreadState thread_state; /* (atomic) */
317+ gboolean weak_notify_ran = FALSE; /* (atomic) */
318 gboolean callback_ran;
319 gboolean notification_emitted = FALSE;
320
321@@ -1498,7 +1498,7 @@ test_return_on_cancel (void)
322 * early.
323 */
324 callback_ran = FALSE;
325- thread_state = THREAD_STARTING;
326+ g_atomic_int_set (&thread_state, THREAD_STARTING);
327 task = g_task_new (NULL, cancellable, return_on_cancel_callback, &callback_ran);
328 g_signal_connect (task, "notify::completed",
329 (GCallback) completed_cb, &notification_emitted);
330@@ -1509,18 +1509,18 @@ test_return_on_cancel (void)
331 g_task_run_in_thread (task, return_on_cancel_thread);
332 g_object_unref (task);
333
334- while (thread_state == THREAD_STARTING)
335+ while (g_atomic_int_get (&thread_state) == THREAD_STARTING)
336 g_cond_wait (&roc_init_cond, &roc_init_mutex);
337 g_mutex_unlock (&roc_init_mutex);
338
339- g_assert (thread_state == THREAD_RUNNING);
340+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_RUNNING);
341 g_assert (callback_ran == FALSE);
342
343 g_cancellable_cancel (cancellable);
344 g_mutex_unlock (&roc_finish_mutex);
345 g_main_loop_run (loop);
346
347- g_assert (thread_state == THREAD_COMPLETED);
348+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_COMPLETED);
349 g_assert (callback_ran == TRUE);
350 g_assert_true (notification_emitted);
351
352@@ -1529,7 +1529,7 @@ test_return_on_cancel (void)
353 /* If return-on-cancel is TRUE, it does return early */
354 callback_ran = FALSE;
355 notification_emitted = FALSE;
356- thread_state = THREAD_STARTING;
357+ g_atomic_int_set (&thread_state, THREAD_STARTING);
358 task = g_task_new (NULL, cancellable, return_on_cancel_callback, &callback_ran);
359 g_object_weak_ref (G_OBJECT (task), task_weak_notify, (gpointer)&weak_notify_ran);
360 g_signal_connect (task, "notify::completed",
361@@ -1542,27 +1542,27 @@ test_return_on_cancel (void)
362 g_task_run_in_thread (task, return_on_cancel_thread);
363 g_object_unref (task);
364
365- while (thread_state == THREAD_STARTING)
366+ while (g_atomic_int_get (&thread_state) == THREAD_STARTING)
367 g_cond_wait (&roc_init_cond, &roc_init_mutex);
368 g_mutex_unlock (&roc_init_mutex);
369
370- g_assert (thread_state == THREAD_RUNNING);
371+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_RUNNING);
372 g_assert (callback_ran == FALSE);
373
374 g_cancellable_cancel (cancellable);
375 g_main_loop_run (loop);
376- g_assert (thread_state == THREAD_RUNNING);
377+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_RUNNING);
378 g_assert (callback_ran == TRUE);
379
380- g_assert (weak_notify_ran == FALSE);
381+ g_assert_false (g_atomic_int_get (&weak_notify_ran));
382
383- while (thread_state == THREAD_RUNNING)
384+ while (g_atomic_int_get (&thread_state) == THREAD_RUNNING)
385 g_cond_wait (&roc_finish_cond, &roc_finish_mutex);
386 g_mutex_unlock (&roc_finish_mutex);
387
388- g_assert (thread_state == THREAD_CANCELLED);
389+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_CANCELLED);
390 g_mutex_lock (&run_in_thread_mutex);
391- while (!weak_notify_ran)
392+ while (!g_atomic_int_get (&weak_notify_ran))
393 g_cond_wait (&run_in_thread_cond, &run_in_thread_mutex);
394 g_mutex_unlock (&run_in_thread_mutex);
395
396@@ -1574,7 +1574,7 @@ test_return_on_cancel (void)
397 */
398 callback_ran = FALSE;
399 notification_emitted = FALSE;
400- thread_state = THREAD_STARTING;
401+ g_atomic_int_set (&thread_state, THREAD_STARTING);
402 task = g_task_new (NULL, cancellable, return_on_cancel_callback, &callback_ran);
403 g_signal_connect (task, "notify::completed",
404 (GCallback) completed_cb, &notification_emitted);
405@@ -1591,17 +1591,17 @@ test_return_on_cancel (void)
406 g_main_loop_run (loop);
407 g_assert (callback_ran == TRUE);
408
409- while (thread_state == THREAD_STARTING)
410+ while (g_atomic_int_get (&thread_state) == THREAD_STARTING)
411 g_cond_wait (&roc_init_cond, &roc_init_mutex);
412 g_mutex_unlock (&roc_init_mutex);
413
414- g_assert (thread_state == THREAD_RUNNING);
415+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_RUNNING);
416
417- while (thread_state == THREAD_RUNNING)
418+ while (g_atomic_int_get (&thread_state) == THREAD_RUNNING)
419 g_cond_wait (&roc_finish_cond, &roc_finish_mutex);
420 g_mutex_unlock (&roc_finish_mutex);
421
422- g_assert (thread_state == THREAD_CANCELLED);
423+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_CANCELLED);
424 g_assert_true (notification_emitted);
425
426 g_object_unref (cancellable);
427@@ -1621,7 +1621,7 @@ test_return_on_cancel_sync (void)
428 {
429 GTask *task;
430 GCancellable *cancellable;
431- volatile ThreadState thread_state;
432+ ThreadState thread_state; /* (atomic) */
433 GThread *runner_thread;
434 gssize ret;
435 GError *error = NULL;
436@@ -1630,7 +1630,7 @@ test_return_on_cancel_sync (void)
437
438 /* If return-on-cancel is FALSE, the task does not return early.
439 */
440- thread_state = THREAD_STARTING;
441+ g_atomic_int_set (&thread_state, THREAD_STARTING);
442 task = g_task_new (NULL, cancellable, run_in_thread_sync_callback, NULL);
443
444 g_task_set_task_data (task, (gpointer)&thread_state, NULL);
445@@ -1639,16 +1639,16 @@ test_return_on_cancel_sync (void)
446 runner_thread = g_thread_new ("return-on-cancel-sync runner thread",
447 cancel_sync_runner_thread, task);
448
449- while (thread_state == THREAD_STARTING)
450+ while (g_atomic_int_get (&thread_state) == THREAD_STARTING)
451 g_cond_wait (&roc_init_cond, &roc_init_mutex);
452 g_mutex_unlock (&roc_init_mutex);
453
454- g_assert (thread_state == THREAD_RUNNING);
455+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_RUNNING);
456
457 g_cancellable_cancel (cancellable);
458 g_mutex_unlock (&roc_finish_mutex);
459 g_thread_join (runner_thread);
460- g_assert (thread_state == THREAD_COMPLETED);
461+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_COMPLETED);
462
463 ret = g_task_propagate_int (task, &error);
464 g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
465@@ -1660,7 +1660,7 @@ test_return_on_cancel_sync (void)
466 g_cancellable_reset (cancellable);
467
468 /* If return-on-cancel is TRUE, it does return early */
469- thread_state = THREAD_STARTING;
470+ g_atomic_int_set (&thread_state, THREAD_STARTING);
471 task = g_task_new (NULL, cancellable, run_in_thread_sync_callback, NULL);
472 g_task_set_return_on_cancel (task, TRUE);
473
474@@ -1670,15 +1670,15 @@ test_return_on_cancel_sync (void)
475 runner_thread = g_thread_new ("return-on-cancel-sync runner thread",
476 cancel_sync_runner_thread, task);
477
478- while (thread_state == THREAD_STARTING)
479+ while (g_atomic_int_get (&thread_state) == THREAD_STARTING)
480 g_cond_wait (&roc_init_cond, &roc_init_mutex);
481 g_mutex_unlock (&roc_init_mutex);
482
483- g_assert (thread_state == THREAD_RUNNING);
484+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_RUNNING);
485
486 g_cancellable_cancel (cancellable);
487 g_thread_join (runner_thread);
488- g_assert (thread_state == THREAD_RUNNING);
489+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_RUNNING);
490
491 ret = g_task_propagate_int (task, &error);
492 g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
493@@ -1687,18 +1687,18 @@ test_return_on_cancel_sync (void)
494
495 g_object_unref (task);
496
497- while (thread_state == THREAD_RUNNING)
498+ while (g_atomic_int_get (&thread_state) == THREAD_RUNNING)
499 g_cond_wait (&roc_finish_cond, &roc_finish_mutex);
500 g_mutex_unlock (&roc_finish_mutex);
501
502- g_assert (thread_state == THREAD_CANCELLED);
503+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_CANCELLED);
504
505 g_cancellable_reset (cancellable);
506
507 /* If the task is already cancelled before it starts, it returns
508 * immediately, but the thread func still runs.
509 */
510- thread_state = THREAD_STARTING;
511+ g_atomic_int_set (&thread_state, THREAD_STARTING);
512 task = g_task_new (NULL, cancellable, run_in_thread_sync_callback, NULL);
513 g_task_set_return_on_cancel (task, TRUE);
514
515@@ -1711,7 +1711,7 @@ test_return_on_cancel_sync (void)
516 cancel_sync_runner_thread, task);
517
518 g_thread_join (runner_thread);
519- g_assert (thread_state == THREAD_STARTING);
520+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_STARTING);
521
522 ret = g_task_propagate_int (task, &error);
523 g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
524@@ -1720,17 +1720,17 @@ test_return_on_cancel_sync (void)
525
526 g_object_unref (task);
527
528- while (thread_state == THREAD_STARTING)
529+ while (g_atomic_int_get (&thread_state) == THREAD_STARTING)
530 g_cond_wait (&roc_init_cond, &roc_init_mutex);
531 g_mutex_unlock (&roc_init_mutex);
532
533- g_assert (thread_state == THREAD_RUNNING);
534+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_RUNNING);
535
536- while (thread_state == THREAD_RUNNING)
537+ while (g_atomic_int_get (&thread_state) == THREAD_RUNNING)
538 g_cond_wait (&roc_finish_cond, &roc_finish_mutex);
539 g_mutex_unlock (&roc_finish_mutex);
540
541- g_assert (thread_state == THREAD_CANCELLED);
542+ g_assert_cmpint (g_atomic_int_get (&thread_state), ==, THREAD_CANCELLED);
543
544 g_object_unref (cancellable);
545 }
546@@ -1776,7 +1776,7 @@ return_on_cancel_atomic_thread (GTask
547 gpointer task_data,
548 GCancellable *cancellable)
549 {
550- gint *state = task_data;
551+ gint *state = task_data; /* (atomic) */
552
553 g_assert (source_object == g_task_get_source_object (task));
554 g_assert (task_data == g_task_get_task_data (task));
555@@ -1784,34 +1784,34 @@ return_on_cancel_atomic_thread (GTask
556 g_assert_false (g_task_get_completed (task));
557
558 g_assert (g_thread_self () != main_thread);
559- g_assert_cmpint (*state, ==, 0);
560+ g_assert_cmpint (g_atomic_int_get (state), ==, 0);
561
562 g_mutex_lock (&roca_mutex_1);
563- *state = 1;
564+ g_atomic_int_set (state, 1);
565 g_cond_signal (&roca_cond_1);
566 g_mutex_unlock (&roca_mutex_1);
567
568 g_mutex_lock (&roca_mutex_2);
569 if (g_task_set_return_on_cancel (task, FALSE))
570- *state = 2;
571+ g_atomic_int_set (state, 2);
572 else
573- *state = 3;
574+ g_atomic_int_set (state, 3);
575 g_cond_signal (&roca_cond_2);
576 g_mutex_unlock (&roca_mutex_2);
577
578 g_mutex_lock (&roca_mutex_1);
579 if (g_task_set_return_on_cancel (task, TRUE))
580- *state = 4;
581+ g_atomic_int_set (state, 4);
582 else
583- *state = 5;
584+ g_atomic_int_set (state, 5);
585 g_cond_signal (&roca_cond_1);
586 g_mutex_unlock (&roca_mutex_1);
587
588 g_mutex_lock (&roca_mutex_2);
589 if (g_task_set_return_on_cancel (task, TRUE))
590- *state = 6;
591+ g_atomic_int_set (state, 6);
592 else
593- *state = 7;
594+ g_atomic_int_set (state, 7);
595 g_cond_signal (&roca_cond_2);
596 g_mutex_unlock (&roca_mutex_2);
597
598@@ -1823,7 +1823,7 @@ test_return_on_cancel_atomic (void)
599 {
600 GTask *task;
601 GCancellable *cancellable;
602- volatile gint state;
603+ gint state; /* (atomic) */
604 gboolean notification_emitted = FALSE;
605 gboolean callback_ran;
606
607@@ -1832,7 +1832,7 @@ test_return_on_cancel_atomic (void)
608 g_mutex_lock (&roca_mutex_2);
609
610 /* If we don't cancel it, each set_return_on_cancel() call will succeed */
611- state = 0;
612+ g_atomic_int_set (&state, 0);
613 callback_ran = FALSE;
614 task = g_task_new (NULL, cancellable, return_on_cancel_atomic_callback, &callback_ran);
615 g_task_set_return_on_cancel (task, TRUE);
616@@ -1843,23 +1843,23 @@ test_return_on_cancel_atomic (void)
617 g_task_run_in_thread (task, return_on_cancel_atomic_thread);
618 g_object_unref (task);
619
620- g_assert_cmpint (state, ==, 0);
621+ g_assert_cmpint (g_atomic_int_get (&state), ==, 0);
622
623- while (state == 0)
624+ while (g_atomic_int_get (&state) == 0)
625 g_cond_wait (&roca_cond_1, &roca_mutex_1);
626- g_assert (state == 1);
627+ g_assert_cmpint (g_atomic_int_get (&state), ==, 1);
628
629- while (state == 1)
630+ while (g_atomic_int_get (&state) == 1)
631 g_cond_wait (&roca_cond_2, &roca_mutex_2);
632- g_assert (state == 2);
633+ g_assert_cmpint (g_atomic_int_get (&state), ==, 2);
634
635- while (state == 2)
636+ while (g_atomic_int_get (&state) == 2)
637 g_cond_wait (&roca_cond_1, &roca_mutex_1);
638- g_assert (state == 4);
639+ g_assert_cmpint (g_atomic_int_get (&state), ==, 4);
640
641- while (state == 4)
642+ while (g_atomic_int_get (&state) == 4)
643 g_cond_wait (&roca_cond_2, &roca_mutex_2);
644- g_assert (state == 6);
645+ g_assert_cmpint (g_atomic_int_get (&state), ==, 6);
646
647 /* callback assumes there'll be a cancelled error */
648 g_cancellable_cancel (cancellable);
649@@ -1876,7 +1876,7 @@ test_return_on_cancel_atomic (void)
650 * task won't complete right away, and further
651 * g_task_set_return_on_cancel() calls will return FALSE.
652 */
653- state = 0;
654+ g_atomic_int_set (&state, 0);
655 callback_ran = FALSE;
656 notification_emitted = FALSE;
657 task = g_task_new (NULL, cancellable, return_on_cancel_atomic_callback, &callback_ran);
658@@ -1887,16 +1887,16 @@ test_return_on_cancel_atomic (void)
659 g_task_set_task_data (task, (gpointer)&state, NULL);
660 g_task_run_in_thread (task, return_on_cancel_atomic_thread);
661
662- g_assert_cmpint (state, ==, 0);
663+ g_assert_cmpint (g_atomic_int_get (&state), ==, 0);
664
665- while (state == 0)
666+ while (g_atomic_int_get (&state) == 0)
667 g_cond_wait (&roca_cond_1, &roca_mutex_1);
668- g_assert (state == 1);
669+ g_assert_cmpint (g_atomic_int_get (&state), ==, 1);
670 g_assert (g_task_get_return_on_cancel (task));
671
672- while (state == 1)
673+ while (g_atomic_int_get (&state) == 1)
674 g_cond_wait (&roca_cond_2, &roca_mutex_2);
675- g_assert (state == 2);
676+ g_assert_cmpint (g_atomic_int_get (&state), ==, 2);
677 g_assert (!g_task_get_return_on_cancel (task));
678
679 g_cancellable_cancel (cancellable);
680@@ -1904,18 +1904,18 @@ test_return_on_cancel_atomic (void)
681 g_main_loop_run (loop);
682 g_assert (callback_ran == FALSE);
683
684- while (state == 2)
685+ while (g_atomic_int_get (&state) == 2)
686 g_cond_wait (&roca_cond_1, &roca_mutex_1);
687- g_assert (state == 5);
688+ g_assert_cmpint (g_atomic_int_get (&state), ==, 5);
689 g_assert (!g_task_get_return_on_cancel (task));
690
691 g_main_loop_run (loop);
692 g_assert (callback_ran == TRUE);
693 g_assert_true (notification_emitted);
694
695- while (state == 5)
696+ while (g_atomic_int_get (&state) == 5)
697 g_cond_wait (&roca_cond_2, &roca_mutex_2);
698- g_assert (state == 7);
699+ g_assert_cmpint (g_atomic_int_get (&state), ==, 7);
700
701 g_object_unref (cancellable);
702 g_mutex_unlock (&roca_mutex_1);
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0006-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch b/meta/recipes-core/glib-2.0/glib-2.0/0006-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
new file mode 100644
index 0000000000..7f22b4d46b
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0006-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
@@ -0,0 +1,35 @@
1From f4607def1695efb50eb49e0586eed0f5557935f2 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:20:37 +0000
4Subject: [PATCH 06/29] tests: Drop unnecessary volatile qualifiers from tests
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9These variables were already (correctly) accessed atomically. The
10`volatile` qualifier doesn’t help with that.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 gio/tests/g-file-info.c | 2 +-
18 1 file changed, 1 insertion(+), 1 deletion(-)
19
20diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c
21index 809b0ec79..1a02b5e0e 100644
22--- a/gio/tests/g-file-info.c
23+++ b/gio/tests/g-file-info.c
24@@ -221,7 +221,7 @@ test_internal_enhanced_stdio (void)
25 guint64 size_p0, alsize_p0, size_ps, alsize_ps;
26 const gchar *id_p0;
27 const gchar *id_p1;
28- volatile guint64 time_p0;
29+ guint64 time_p0;
30 gchar *tmp_dir;
31 wchar_t *programdata_dir_w;
32 wchar_t *users_dir_w;
33--
342.30.1
35
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0007-gdbusconnection-Drop-unnecessary-volatile-qualifiers.patch b/meta/recipes-core/glib-2.0/glib-2.0/0007-gdbusconnection-Drop-unnecessary-volatile-qualifiers.patch
new file mode 100644
index 0000000000..78753f821a
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0007-gdbusconnection-Drop-unnecessary-volatile-qualifiers.patch
@@ -0,0 +1,111 @@
1From 33612404397f87f0cd45da90d3aa9ab60df895ee Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:24:28 +0000
4Subject: [PATCH 07/29] gdbusconnection: Drop unnecessary volatile qualifiers
5 from variables
6
7This should introduce no API changes; there are public functions
8exported by `GDBusConnection` which still have some (incorrectly)
9`volatile` arguments, but dropping those qualifiers would be an API
10break.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 gio/gdbusconnection.c | 22 +++++++++++-----------
18 1 file changed, 11 insertions(+), 11 deletions(-)
19
20diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
21index ed8cf6219..91c365e80 100644
22--- a/gio/gdbusconnection.c
23+++ b/gio/gdbusconnection.c
24@@ -393,7 +393,7 @@ struct _GDBusConnection
25 * FLAG_CLOSED is the closed property. It may be read at any time, but
26 * may only be written while holding @lock.
27 */
28- volatile gint atomic_flags;
29+ gint atomic_flags; /* (atomic) */
30
31 /* If the connection could not be established during initable_init(),
32 * this GError will be set.
33@@ -1596,7 +1596,7 @@ static gboolean
34 g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
35 GDBusMessage *message,
36 GDBusSendMessageFlags flags,
37- volatile guint32 *out_serial,
38+ guint32 *out_serial,
39 GError **error)
40 {
41 guchar *blob;
42@@ -1741,7 +1741,7 @@ g_dbus_connection_send_message (GDBusConnection *connection,
43 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
44
45 CONNECTION_LOCK (connection);
46- ret = g_dbus_connection_send_message_unlocked (connection, message, flags, out_serial, error);
47+ ret = g_dbus_connection_send_message_unlocked (connection, message, flags, (guint32 *) out_serial, error);
48 CONNECTION_UNLOCK (connection);
49 return ret;
50 }
51@@ -1901,7 +1901,7 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect
52 GDBusMessage *message,
53 GDBusSendMessageFlags flags,
54 gint timeout_msec,
55- volatile guint32 *out_serial,
56+ guint32 *out_serial,
57 GCancellable *cancellable,
58 GAsyncReadyCallback callback,
59 gpointer user_data)
60@@ -1909,7 +1909,7 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect
61 GTask *task;
62 SendMessageData *data;
63 GError *error = NULL;
64- volatile guint32 serial;
65+ guint32 serial;
66
67 if (out_serial == NULL)
68 out_serial = &serial;
69@@ -2022,7 +2022,7 @@ g_dbus_connection_send_message_with_reply (GDBusConnection *connection,
70 message,
71 flags,
72 timeout_msec,
73- out_serial,
74+ (guint32 *) out_serial,
75 cancellable,
76 callback,
77 user_data);
78@@ -3082,7 +3082,7 @@ g_dbus_connection_get_peer_credentials (GDBusConnection *connection)
79
80 /* ---------------------------------------------------------------------------------------------------- */
81
82-static volatile guint _global_filter_id = 1;
83+static guint _global_filter_id = 1; /* (atomic) */
84
85 /**
86 * g_dbus_connection_add_filter:
87@@ -3327,9 +3327,9 @@ args_to_rule (const gchar *sender,
88 return g_string_free (rule, FALSE);
89 }
90
91-static volatile guint _global_subscriber_id = 1;
92-static volatile guint _global_registration_id = 1;
93-static volatile guint _global_subtree_registration_id = 1;
94+static guint _global_subscriber_id = 1; /* (atomic) */
95+static guint _global_registration_id = 1; /* (atomic) */
96+static guint _global_subtree_registration_id = 1; /* (atomic) */
97
98 /* ---------------------------------------------------------------------------------------------------- */
99
100@@ -5992,7 +5992,7 @@ g_dbus_connection_call_sync_internal (GDBusConnection *connection,
101 message,
102 send_flags,
103 timeout_msec,
104- NULL, /* volatile guint32 *out_serial */
105+ NULL, /* guint32 *out_serial */
106 cancellable,
107 &local_error);
108
109--
1102.30.1
111
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0008-gdbuserror-Drop-unnecessary-volatile-qualifiers-from.patch b/meta/recipes-core/glib-2.0/glib-2.0/0008-gdbuserror-Drop-unnecessary-volatile-qualifiers-from.patch
new file mode 100644
index 0000000000..e947a264c5
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0008-gdbuserror-Drop-unnecessary-volatile-qualifiers-from.patch
@@ -0,0 +1,95 @@
1From 7c7623c4a31fb0f2a7176c43acc728093818b58c Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:26:19 +0000
4Subject: [PATCH 08/29] gdbuserror: Drop unnecessary volatile qualifiers from
5 variables
6
7This should introduce no API changes. The
8`g_dbus_error_register_error_domain()` function still (incorrectly) has
9a `volatile` argument, but dropping that qualifier would be an API
10break.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 gio/gdbuserror.c | 28 +++++++++++++++++-----------
18 1 file changed, 17 insertions(+), 11 deletions(-)
19
20diff --git a/gio/gdbuserror.c b/gio/gdbuserror.c
21index 682677354..b03a33f27 100644
22--- a/gio/gdbuserror.c
23+++ b/gio/gdbuserror.c
24@@ -84,12 +84,12 @@
25 * GQuark
26 * foo_bar_error_quark (void)
27 * {
28- * static volatile gsize quark_volatile = 0;
29+ * static gsize quark = 0;
30 * g_dbus_error_register_error_domain ("foo-bar-error-quark",
31- * &quark_volatile,
32+ * &quark,
33 * foo_bar_error_entries,
34 * G_N_ELEMENTS (foo_bar_error_entries));
35- * return (GQuark) quark_volatile;
36+ * return (GQuark) quark;
37 * }
38 * ]|
39 * With this setup, a D-Bus peer can transparently pass e.g. %FOO_BAR_ERROR_ANOTHER_ERROR and
40@@ -160,12 +160,12 @@ GQuark
41 g_dbus_error_quark (void)
42 {
43 G_STATIC_ASSERT (G_N_ELEMENTS (g_dbus_error_entries) - 1 == G_DBUS_ERROR_PROPERTY_READ_ONLY);
44- static volatile gsize quark_volatile = 0;
45+ static gsize quark = 0;
46 g_dbus_error_register_error_domain ("g-dbus-error-quark",
47- &quark_volatile,
48+ &quark,
49 g_dbus_error_entries,
50 G_N_ELEMENTS (g_dbus_error_entries));
51- return (GQuark) quark_volatile;
52+ return (GQuark) quark;
53 }
54
55 /**
56@@ -185,25 +185,31 @@ g_dbus_error_register_error_domain (const gchar *error_domain_quark_na
57 const GDBusErrorEntry *entries,
58 guint num_entries)
59 {
60+ gsize *quark;
61+
62 g_return_if_fail (error_domain_quark_name != NULL);
63 g_return_if_fail (quark_volatile != NULL);
64 g_return_if_fail (entries != NULL);
65 g_return_if_fail (num_entries > 0);
66
67- if (g_once_init_enter (quark_volatile))
68+ /* Drop the volatile qualifier, which should never have been on the argument
69+ * in the first place. */
70+ quark = (gsize *) quark_volatile;
71+
72+ if (g_once_init_enter (quark))
73 {
74 guint n;
75- GQuark quark;
76+ GQuark new_quark;
77
78- quark = g_quark_from_static_string (error_domain_quark_name);
79+ new_quark = g_quark_from_static_string (error_domain_quark_name);
80
81 for (n = 0; n < num_entries; n++)
82 {
83- g_warn_if_fail (g_dbus_error_register_error (quark,
84+ g_warn_if_fail (g_dbus_error_register_error (new_quark,
85 entries[n].error_code,
86 entries[n].dbus_error_name));
87 }
88- g_once_init_leave (quark_volatile, quark);
89+ g_once_init_leave (quark, new_quark);
90 }
91 }
92
93--
942.30.1
95
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0009-gio-Drop-unnecessary-volatile-qualifiers-from-intern.patch b/meta/recipes-core/glib-2.0/glib-2.0/0009-gio-Drop-unnecessary-volatile-qualifiers-from-intern.patch
new file mode 100644
index 0000000000..7897d43bb0
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0009-gio-Drop-unnecessary-volatile-qualifiers-from-intern.patch
@@ -0,0 +1,207 @@
1From 74250cd9c9dfd3ad428e445c095ceac88ba18691 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:28:23 +0000
4Subject: [PATCH 09/29] gio: Drop unnecessary volatile qualifiers from internal
5 variables
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10These variables were already (correctly) accessed atomically. The
11`volatile` qualifier doesn’t help with that.
12
13Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
14
15Helps: #600
16Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
17---
18 gio/gdbusinterfaceskeleton.c | 2 +-
19 gio/gdbusintrospection.h | 14 +++++++-------
20 gio/gdbusnameowning.c | 4 ++--
21 gio/gdbusnamewatching.c | 4 ++--
22 gio/gdbusprivate.c | 10 +++++-----
23 gio/gnetworking.c | 2 +-
24 6 files changed, 18 insertions(+), 18 deletions(-)
25
26diff --git a/gio/gdbusinterfaceskeleton.c b/gio/gdbusinterfaceskeleton.c
27index 243b4a0a4..76398df36 100644
28--- a/gio/gdbusinterfaceskeleton.c
29+++ b/gio/gdbusinterfaceskeleton.c
30@@ -458,7 +458,7 @@ dbus_interface_interface_init (GDBusInterfaceIface *iface)
31
32 typedef struct
33 {
34- volatile gint ref_count;
35+ gint ref_count; /* (atomic) */
36 GDBusInterfaceSkeleton *interface;
37 GDBusInterfaceMethodCallFunc method_call_func;
38 GDBusMethodInvocation *invocation;
39diff --git a/gio/gdbusintrospection.h b/gio/gdbusintrospection.h
40index 14b171055..f2e291787 100644
41--- a/gio/gdbusintrospection.h
42+++ b/gio/gdbusintrospection.h
43@@ -43,7 +43,7 @@ G_BEGIN_DECLS
44 struct _GDBusAnnotationInfo
45 {
46 /*< public >*/
47- volatile gint ref_count;
48+ gint ref_count; /* (atomic) */
49 gchar *key;
50 gchar *value;
51 GDBusAnnotationInfo **annotations;
52@@ -63,7 +63,7 @@ struct _GDBusAnnotationInfo
53 struct _GDBusArgInfo
54 {
55 /*< public >*/
56- volatile gint ref_count;
57+ gint ref_count; /* (atomic) */
58 gchar *name;
59 gchar *signature;
60 GDBusAnnotationInfo **annotations;
61@@ -84,7 +84,7 @@ struct _GDBusArgInfo
62 struct _GDBusMethodInfo
63 {
64 /*< public >*/
65- volatile gint ref_count;
66+ gint ref_count; /* (atomic) */
67 gchar *name;
68 GDBusArgInfo **in_args;
69 GDBusArgInfo **out_args;
70@@ -105,7 +105,7 @@ struct _GDBusMethodInfo
71 struct _GDBusSignalInfo
72 {
73 /*< public >*/
74- volatile gint ref_count;
75+ gint ref_count; /* (atomic) */
76 gchar *name;
77 GDBusArgInfo **args;
78 GDBusAnnotationInfo **annotations;
79@@ -126,7 +126,7 @@ struct _GDBusSignalInfo
80 struct _GDBusPropertyInfo
81 {
82 /*< public >*/
83- volatile gint ref_count;
84+ gint ref_count; /* (atomic) */
85 gchar *name;
86 gchar *signature;
87 GDBusPropertyInfoFlags flags;
88@@ -149,7 +149,7 @@ struct _GDBusPropertyInfo
89 struct _GDBusInterfaceInfo
90 {
91 /*< public >*/
92- volatile gint ref_count;
93+ gint ref_count; /* (atomic) */
94 gchar *name;
95 GDBusMethodInfo **methods;
96 GDBusSignalInfo **signals;
97@@ -172,7 +172,7 @@ struct _GDBusInterfaceInfo
98 struct _GDBusNodeInfo
99 {
100 /*< public >*/
101- volatile gint ref_count;
102+ gint ref_count; /* (atomic) */
103 gchar *path;
104 GDBusInterfaceInfo **interfaces;
105 GDBusNodeInfo **nodes;
106diff --git a/gio/gdbusnameowning.c b/gio/gdbusnameowning.c
107index d20e6ffed..1130d6789 100644
108--- a/gio/gdbusnameowning.c
109+++ b/gio/gdbusnameowning.c
110@@ -55,7 +55,7 @@ typedef enum
111
112 typedef struct
113 {
114- volatile gint ref_count;
115+ gint ref_count; /* (atomic) */
116 guint id;
117 GBusNameOwnerFlags flags;
118 gchar *name;
119@@ -73,7 +73,7 @@ typedef struct
120 guint name_acquired_subscription_id;
121 guint name_lost_subscription_id;
122
123- volatile gboolean cancelled; /* must hold lock when reading or modifying */
124+ gboolean cancelled; /* must hold lock when reading or modifying */
125
126 gboolean needs_release;
127 } Client;
128diff --git a/gio/gdbusnamewatching.c b/gio/gdbusnamewatching.c
129index bc2a9119e..8d24700c5 100644
130--- a/gio/gdbusnamewatching.c
131+++ b/gio/gdbusnamewatching.c
132@@ -56,7 +56,7 @@ typedef enum
133
134 typedef struct
135 {
136- volatile gint ref_count;
137+ gint ref_count; /* (atomic) */
138 guint id;
139 gchar *name;
140 GBusNameWatcherFlags flags;
141@@ -78,7 +78,7 @@ typedef struct
142 } Client;
143
144 /* Must be accessed atomically. */
145-static volatile guint next_global_id = 1;
146+static guint next_global_id = 1; /* (atomic) */
147
148 /* Must be accessed with @lock held. */
149 static GHashTable *map_id_to_client = NULL;
150diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
151index 2551e4791..99b37f3eb 100644
152--- a/gio/gdbusprivate.c
153+++ b/gio/gdbusprivate.c
154@@ -265,7 +265,7 @@ ensure_required_types (void)
155
156 typedef struct
157 {
158- volatile gint refcount;
159+ gint refcount; /* (atomic) */
160 GThread *thread;
161 GMainContext *context;
162 GMainLoop *loop;
163@@ -341,12 +341,12 @@ typedef enum {
164
165 struct GDBusWorker
166 {
167- volatile gint ref_count;
168+ gint ref_count; /* (atomic) */
169
170 SharedThreadData *shared_thread_data;
171
172 /* really a boolean, but GLib 2.28 lacks atomic boolean ops */
173- volatile gint stopped;
174+ gint stopped; /* (atomic) */
175
176 /* TODO: frozen (e.g. G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING) currently
177 * only affects messages received from the other peer (since GDBusServer is the
178@@ -1941,11 +1941,11 @@ _g_dbus_debug_print_unlock (void)
179 void
180 _g_dbus_initialize (void)
181 {
182- static volatile gsize initialized = 0;
183+ static gsize initialized = 0;
184
185 if (g_once_init_enter (&initialized))
186 {
187- volatile GQuark g_dbus_error_domain;
188+ GQuark g_dbus_error_domain;
189 const gchar *debug;
190
191 g_dbus_error_domain = G_DBUS_ERROR;
192diff --git a/gio/gnetworking.c b/gio/gnetworking.c
193index 05507fe70..7bc6d73c4 100644
194--- a/gio/gnetworking.c
195+++ b/gio/gnetworking.c
196@@ -61,7 +61,7 @@ void
197 g_networking_init (void)
198 {
199 #ifdef G_OS_WIN32
200- static volatile gsize inited = 0;
201+ static gsize inited = 0;
202
203 if (g_once_init_enter (&inited))
204 {
205--
2062.30.1
207
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0010-kqueue-Fix-unlocked-access-to-shared-variable.patch b/meta/recipes-core/glib-2.0/glib-2.0/0010-kqueue-Fix-unlocked-access-to-shared-variable.patch
new file mode 100644
index 0000000000..e52b709422
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0010-kqueue-Fix-unlocked-access-to-shared-variable.patch
@@ -0,0 +1,51 @@
1From e4e88688a0722237effc56cc21438d0c8e82de88 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:29:26 +0000
4Subject: [PATCH 10/29] kqueue: Fix unlocked access to shared variable
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9And drop the `volatile` qualifier because it doesn’t help.
10
11Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
12
13Helps: #600
14Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
15---
16 gio/kqueue/kqueue-missing.c | 5 +++--
17 1 file changed, 3 insertions(+), 2 deletions(-)
18
19diff --git a/gio/kqueue/kqueue-missing.c b/gio/kqueue/kqueue-missing.c
20index 37af82e5b..d1ffdf4bd 100644
21--- a/gio/kqueue/kqueue-missing.c
22+++ b/gio/kqueue/kqueue-missing.c
23@@ -34,7 +34,7 @@ static gboolean km_debug_enabled = FALSE;
24 static GSList *missing_subs_list = NULL;
25 G_LOCK_DEFINE_STATIC (missing_lock);
26
27-static volatile gboolean scan_missing_running = FALSE;
28+static gboolean scan_missing_running = FALSE; /* must be accessed under @missing_lock */
29
30
31 static gboolean
32@@ -62,7 +62,6 @@ _km_add_missing (kqueue_sub *sub)
33
34 KM_W ("adding %s to missing list\n", sub->filename);
35 missing_subs_list = g_slist_prepend (missing_subs_list, sub);
36- G_UNLOCK (missing_lock);
37
38 if (!scan_missing_running)
39 {
40@@ -73,6 +72,8 @@ _km_add_missing (kqueue_sub *sub)
41 g_source_attach (source, GLIB_PRIVATE_CALL (g_get_worker_context) ());
42 g_source_unref (source);
43 }
44+
45+ G_UNLOCK (missing_lock);
46 }
47
48 /**
49--
502.30.1
51
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0011-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch b/meta/recipes-core/glib-2.0/glib-2.0/0011-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
new file mode 100644
index 0000000000..ea3fd9f6e9
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0011-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
@@ -0,0 +1,126 @@
1From 7cdb68713c1863a27ad82d801756ec74097e8e87 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:30:36 +0000
4Subject: [PATCH 11/29] tests: Drop unnecessary volatile qualifiers from tests
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9These variables were already (correctly) accessed atomically. The
10`volatile` qualifier doesn’t help with that.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 tests/gobject/performance-threaded.c | 2 +-
18 tests/gobject/performance.c | 4 ++--
19 tests/onceinit.c | 16 ++++++++--------
20 3 files changed, 11 insertions(+), 11 deletions(-)
21
22diff --git a/tests/gobject/performance-threaded.c b/tests/gobject/performance-threaded.c
23index 30ea5bd80..c98541d66 100644
24--- a/tests/gobject/performance-threaded.c
25+++ b/tests/gobject/performance-threaded.c
26@@ -52,7 +52,7 @@ static GType liststore_interfaces[6];
27 static gpointer
28 register_types (void)
29 {
30- static volatile gsize inited = 0;
31+ static gsize inited = 0;
32 if (g_once_init_enter (&inited))
33 {
34 liststore_interfaces[0] = simple_register_class ("GtkBuildable", G_TYPE_INTERFACE, 0);
35diff --git a/tests/gobject/performance.c b/tests/gobject/performance.c
36index 236ffaed0..163be58b4 100644
37--- a/tests/gobject/performance.c
38+++ b/tests/gobject/performance.c
39@@ -575,8 +575,8 @@ test_type_check_run (PerformanceTest *test,
40 gpointer _data)
41 {
42 struct TypeCheckTest *data = _data;
43- volatile GObject *object = data->object;
44- volatile GType type, types[5];
45+ GObject *object = data->object;
46+ GType type, types[5];
47 int i, j;
48
49 types[0] = test_iface1_get_type ();
50diff --git a/tests/onceinit.c b/tests/onceinit.c
51index 89ba6a136..9788efcbd 100644
52--- a/tests/onceinit.c
53+++ b/tests/onceinit.c
54@@ -25,13 +25,13 @@
55
56 static GMutex tmutex;
57 static GCond tcond;
58-static volatile int thread_call_count = 0;
59+static int thread_call_count = 0; /* (atomic) */
60 static char dummy_value = 'x';
61
62 static void
63 assert_singleton_execution1 (void)
64 {
65- static volatile int seen_execution = 0;
66+ static int seen_execution = 0; /* (atomic) */
67 int old_seen_execution = g_atomic_int_add (&seen_execution, 1);
68 if (old_seen_execution != 0)
69 g_error ("%s: function executed more than once", G_STRFUNC);
70@@ -40,7 +40,7 @@ assert_singleton_execution1 (void)
71 static void
72 assert_singleton_execution2 (void)
73 {
74- static volatile int seen_execution = 0;
75+ static int seen_execution = 0; /* (atomic) */
76 int old_seen_execution = g_atomic_int_add (&seen_execution, 1);
77 if (old_seen_execution != 0)
78 g_error ("%s: function executed more than once", G_STRFUNC);
79@@ -49,7 +49,7 @@ assert_singleton_execution2 (void)
80 static void
81 assert_singleton_execution3 (void)
82 {
83- static volatile int seen_execution = 0;
84+ static int seen_execution = 0; /* (atomic) */
85 int old_seen_execution = g_atomic_int_add (&seen_execution, 1);
86 if (old_seen_execution != 0)
87 g_error ("%s: function executed more than once", G_STRFUNC);
88@@ -58,7 +58,7 @@ assert_singleton_execution3 (void)
89 static void
90 initializer1 (void)
91 {
92- static volatile gsize initialized = 0;
93+ static gsize initialized = 0;
94 if (g_once_init_enter (&initialized))
95 {
96 gsize initval = 42;
97@@ -70,7 +70,7 @@ initializer1 (void)
98 static gpointer
99 initializer2 (void)
100 {
101- static volatile gsize initialized = 0;
102+ static gsize initialized = 0;
103 if (g_once_init_enter (&initialized))
104 {
105 void *pointer_value = &dummy_value;
106@@ -83,7 +83,7 @@ initializer2 (void)
107 static void
108 initializer3 (void)
109 {
110- static volatile gsize initialized = 0;
111+ static gsize initialized = 0;
112 if (g_once_init_enter (&initialized))
113 {
114 gsize initval = 42;
115@@ -163,7 +163,7 @@ main (int argc,
116 static void \
117 test_initializer_##N (void) \
118 { \
119- static volatile gsize initialized = 0; \
120+ static gsize initialized = 0; \
121 if (g_once_init_enter (&initialized)) \
122 { \
123 g_free (g_strdup_printf ("cpuhog%5d", 1)); \
124--
1252.30.1
126
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0012-tests-Fix-non-atomic-access-to-some-shared-variables.patch b/meta/recipes-core/glib-2.0/glib-2.0/0012-tests-Fix-non-atomic-access-to-some-shared-variables.patch
new file mode 100644
index 0000000000..be7fcba8c8
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0012-tests-Fix-non-atomic-access-to-some-shared-variables.patch
@@ -0,0 +1,103 @@
1From 1a7f0002a052725fb646e136fadd5dad66222d7f Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:31:01 +0000
4Subject: [PATCH 12/29] tests: Fix non-atomic access to some shared variables
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9And drop the `volatile` qualifier from the variables, as that doesn’t
10help with thread safety.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 tests/refcount/objects.c | 8 ++++----
18 tests/refcount/properties3.c | 8 ++++----
19 2 files changed, 8 insertions(+), 8 deletions(-)
20
21diff --git a/tests/refcount/objects.c b/tests/refcount/objects.c
22index 963766d00..0c471a42b 100644
23--- a/tests/refcount/objects.c
24+++ b/tests/refcount/objects.c
25@@ -26,7 +26,7 @@ struct _GTestClass
26 };
27
28 static GType my_test_get_type (void);
29-static volatile gboolean stopping;
30+static gint stopping; /* (atomic) */
31
32 static void my_test_class_init (GTestClass * klass);
33 static void my_test_init (GTest * test);
34@@ -101,7 +101,7 @@ run_thread (GTest * test)
35 {
36 gint i = 1;
37
38- while (!stopping) {
39+ while (!g_atomic_int_get (&stopping)) {
40 my_test_do_refcount (test);
41 if ((i++ % 10000) == 0) {
42 g_print (".");
43@@ -128,7 +128,7 @@ main (int argc, char **argv)
44
45 test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));
46
47- stopping = FALSE;
48+ g_atomic_int_set (&stopping, 0);
49
50 for (i = 0; i < n_threads; i++) {
51 GThread *thread;
52@@ -141,7 +141,7 @@ main (int argc, char **argv)
53 }
54 g_usleep (5000000);
55
56- stopping = TRUE;
57+ g_atomic_int_set (&stopping, 1);
58
59 g_print ("\nstopping\n");
60
61diff --git a/tests/refcount/properties3.c b/tests/refcount/properties3.c
62index bc8820661..31f26a46e 100644
63--- a/tests/refcount/properties3.c
64+++ b/tests/refcount/properties3.c
65@@ -34,7 +34,7 @@ struct _GTestClass
66 static GType my_test_get_type (void);
67 G_DEFINE_TYPE (GTest, my_test, G_TYPE_OBJECT)
68
69-static volatile gboolean stopping;
70+static gint stopping; /* (atomic) */
71
72 static void my_test_get_property (GObject *object,
73 guint prop_id,
74@@ -140,7 +140,7 @@ run_thread (GTest * test)
75 {
76 gint i = 1;
77
78- while (!stopping) {
79+ while (!g_atomic_int_get (&stopping)) {
80 my_test_do_property (test);
81 if ((i++ % 10000) == 0)
82 {
83@@ -170,7 +170,7 @@ main (int argc, char **argv)
84
85 test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));
86
87- stopping = FALSE;
88+ g_atomic_int_set (&stopping, 0);
89
90 for (i = 0; i < n_threads; i++) {
91 GThread *thread;
92@@ -180,7 +180,7 @@ main (int argc, char **argv)
93 }
94 g_usleep (30000000);
95
96- stopping = TRUE;
97+ g_atomic_int_set (&stopping, 1);
98 g_print ("\nstopping\n");
99
100 /* join all threads */
101--
1022.30.1
103
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0013-gatomic-Drop-unnecessary-volatile-qualifiers-from-in.patch b/meta/recipes-core/glib-2.0/glib-2.0/0013-gatomic-Drop-unnecessary-volatile-qualifiers-from-in.patch
new file mode 100644
index 0000000000..efc6817bd1
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0013-gatomic-Drop-unnecessary-volatile-qualifiers-from-in.patch
@@ -0,0 +1,180 @@
1From 3c648457c284b4ba313b8591008d2e18ae4335eb Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:36:37 +0000
4Subject: [PATCH 13/29] gatomic: Drop unnecessary volatile qualifiers from
5 internal variables
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10It’s not necessary and provides no thread safety guarantees.
11
12The `volatile` qualifiers on the function arguments have to be kept, as
13they are (unfortunately) part of the API.
14
15Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
16
17Helps: #600
18Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
19---
20 glib/gatomic.c | 34 +++++++++++++++++-----------------
21 1 file changed, 17 insertions(+), 17 deletions(-)
22
23diff --git a/glib/gatomic.c b/glib/gatomic.c
24index 8b8c6453d..67f5ba6b4 100644
25--- a/glib/gatomic.c
26+++ b/glib/gatomic.c
27@@ -316,7 +316,7 @@ guint
28 gpointer
29 (g_atomic_pointer_get) (const volatile void *atomic)
30 {
31- return g_atomic_pointer_get ((const volatile gpointer *) atomic);
32+ return g_atomic_pointer_get ((gpointer *) atomic);
33 }
34
35 /**
36@@ -335,7 +335,7 @@ void
37 (g_atomic_pointer_set) (volatile void *atomic,
38 gpointer newval)
39 {
40- g_atomic_pointer_set ((volatile gpointer *) atomic, newval);
41+ g_atomic_pointer_set ((gpointer *) atomic, newval);
42 }
43
44 /**
45@@ -363,7 +363,7 @@ gboolean
46 gpointer oldval,
47 gpointer newval)
48 {
49- return g_atomic_pointer_compare_and_exchange ((volatile gpointer *) atomic,
50+ return g_atomic_pointer_compare_and_exchange ((gpointer *) atomic,
51 oldval, newval);
52 }
53
54@@ -387,7 +387,7 @@ gssize
55 (g_atomic_pointer_add) (volatile void *atomic,
56 gssize val)
57 {
58- return g_atomic_pointer_add ((volatile gpointer *) atomic, val);
59+ return g_atomic_pointer_add ((gpointer *) atomic, val);
60 }
61
62 /**
63@@ -411,7 +411,7 @@ gsize
64 (g_atomic_pointer_and) (volatile void *atomic,
65 gsize val)
66 {
67- return g_atomic_pointer_and ((volatile gpointer *) atomic, val);
68+ return g_atomic_pointer_and ((gpointer *) atomic, val);
69 }
70
71 /**
72@@ -435,7 +435,7 @@ gsize
73 (g_atomic_pointer_or) (volatile void *atomic,
74 gsize val)
75 {
76- return g_atomic_pointer_or ((volatile gpointer *) atomic, val);
77+ return g_atomic_pointer_or ((gpointer *) atomic, val);
78 }
79
80 /**
81@@ -459,7 +459,7 @@ gsize
82 (g_atomic_pointer_xor) (volatile void *atomic,
83 gsize val)
84 {
85- return g_atomic_pointer_xor ((volatile gpointer *) atomic, val);
86+ return g_atomic_pointer_xor ((gpointer *) atomic, val);
87 }
88
89 #elif defined (G_PLATFORM_WIN32)
90@@ -591,7 +591,7 @@ guint
91 gpointer
92 (g_atomic_pointer_get) (const volatile void *atomic)
93 {
94- const volatile gpointer *ptr = atomic;
95+ const gpointer *ptr = atomic;
96
97 MemoryBarrier ();
98 return *ptr;
99@@ -601,7 +601,7 @@ void
100 (g_atomic_pointer_set) (volatile void *atomic,
101 gpointer newval)
102 {
103- volatile gpointer *ptr = atomic;
104+ gpointer *ptr = atomic;
105
106 *ptr = newval;
107 MemoryBarrier ();
108@@ -797,7 +797,7 @@ guint
109 gpointer
110 (g_atomic_pointer_get) (const volatile void *atomic)
111 {
112- const volatile gpointer *ptr = atomic;
113+ const gpointer *ptr = atomic;
114 gpointer value;
115
116 pthread_mutex_lock (&g_atomic_lock);
117@@ -811,7 +811,7 @@ void
118 (g_atomic_pointer_set) (volatile void *atomic,
119 gpointer newval)
120 {
121- volatile gpointer *ptr = atomic;
122+ gpointer *ptr = atomic;
123
124 pthread_mutex_lock (&g_atomic_lock);
125 *ptr = newval;
126@@ -823,7 +823,7 @@ gboolean
127 gpointer oldval,
128 gpointer newval)
129 {
130- volatile gpointer *ptr = atomic;
131+ gpointer *ptr = atomic;
132 gboolean success;
133
134 pthread_mutex_lock (&g_atomic_lock);
135@@ -840,7 +840,7 @@ gssize
136 (g_atomic_pointer_add) (volatile void *atomic,
137 gssize val)
138 {
139- volatile gssize *ptr = atomic;
140+ gssize *ptr = atomic;
141 gssize oldval;
142
143 pthread_mutex_lock (&g_atomic_lock);
144@@ -855,7 +855,7 @@ gsize
145 (g_atomic_pointer_and) (volatile void *atomic,
146 gsize val)
147 {
148- volatile gsize *ptr = atomic;
149+ gsize *ptr = atomic;
150 gsize oldval;
151
152 pthread_mutex_lock (&g_atomic_lock);
153@@ -870,7 +870,7 @@ gsize
154 (g_atomic_pointer_or) (volatile void *atomic,
155 gsize val)
156 {
157- volatile gsize *ptr = atomic;
158+ gsize *ptr = atomic;
159 gsize oldval;
160
161 pthread_mutex_lock (&g_atomic_lock);
162@@ -885,7 +885,7 @@ gsize
163 (g_atomic_pointer_xor) (volatile void *atomic,
164 gsize val)
165 {
166- volatile gsize *ptr = atomic;
167+ gsize *ptr = atomic;
168 gsize oldval;
169
170 pthread_mutex_lock (&g_atomic_lock);
171@@ -915,5 +915,5 @@ gint
172 g_atomic_int_exchange_and_add (volatile gint *atomic,
173 gint val)
174 {
175- return (g_atomic_int_add) (atomic, val);
176+ return (g_atomic_int_add) ((gint *) atomic, val);
177 }
178--
1792.30.1
180
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0014-gatomic-Drop-unnecessary-volatile-qualifiers-from-ma.patch b/meta/recipes-core/glib-2.0/glib-2.0/0014-gatomic-Drop-unnecessary-volatile-qualifiers-from-ma.patch
new file mode 100644
index 0000000000..bcc06e05cd
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0014-gatomic-Drop-unnecessary-volatile-qualifiers-from-ma.patch
@@ -0,0 +1,56 @@
1From 9474655eb21d64519b293e780bb686976cbdb790 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:38:36 +0000
4Subject: [PATCH 14/29] gatomic: Drop unnecessary volatile qualifiers from
5 macro variables
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10It’s not necessary and provides no thread safety guarantees.
11
12The `volatile` qualifiers on the function arguments have to be kept, as
13they are (unfortunately) part of the API.
14
15Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
16
17Helps: #600
18Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
19---
20 glib/gatomic.h | 6 +++---
21 1 file changed, 3 insertions(+), 3 deletions(-)
22
23diff --git a/glib/gatomic.h b/glib/gatomic.h
24index bb1435c70..e6eccfada 100644
25--- a/glib/gatomic.h
26+++ b/glib/gatomic.h
27@@ -211,7 +211,7 @@ G_END_DECLS
28 }))
29 #define g_atomic_pointer_and(atomic, val) \
30 (G_GNUC_EXTENSION ({ \
31- volatile gsize *gapa_atomic = (volatile gsize *) (atomic); \
32+ gsize *gapa_atomic = (gsize *) (atomic); \
33 G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
34 G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \
35 (void) (0 ? (gpointer) *(atomic) : NULL); \
36@@ -220,7 +220,7 @@ G_END_DECLS
37 }))
38 #define g_atomic_pointer_or(atomic, val) \
39 (G_GNUC_EXTENSION ({ \
40- volatile gsize *gapo_atomic = (volatile gsize *) (atomic); \
41+ gsize *gapo_atomic = (gsize *) (atomic); \
42 G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
43 G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \
44 (void) (0 ? (gpointer) *(atomic) : NULL); \
45@@ -229,7 +229,7 @@ G_END_DECLS
46 }))
47 #define g_atomic_pointer_xor(atomic, val) \
48 (G_GNUC_EXTENSION ({ \
49- volatile gsize *gapx_atomic = (volatile gsize *) (atomic); \
50+ gsize *gapx_atomic = (gsize *) (atomic); \
51 G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
52 G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \
53 (void) (0 ? (gpointer) *(atomic) : NULL); \
54--
552.30.1
56
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0015-glib-Drop-unnecessary-volatile-qualifiers-from-inter.patch b/meta/recipes-core/glib-2.0/glib-2.0/0015-glib-Drop-unnecessary-volatile-qualifiers-from-inter.patch
new file mode 100644
index 0000000000..9468548e3a
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0015-glib-Drop-unnecessary-volatile-qualifiers-from-inter.patch
@@ -0,0 +1,169 @@
1From 1314ff93fc4d3379483c33da6a7deff27f71ed95 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:40:56 +0000
4Subject: [PATCH 15/29] glib: Drop unnecessary volatile qualifiers from
5 internal variables
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10These variables were already (correctly) accessed atomically. The
11`volatile` qualifier doesn’t help with that.
12
13Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
14
15Helps: #600
16Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
17---
18 glib/gdatetime.c | 2 +-
19 glib/gkeyfile.c | 2 +-
20 glib/gmain.c | 8 ++++----
21 glib/gmarkup.c | 2 +-
22 glib/gregex.c | 6 +++---
23 glib/gthread.c | 6 +++---
24 6 files changed, 13 insertions(+), 13 deletions(-)
25
26diff --git a/glib/gdatetime.c b/glib/gdatetime.c
27index 1755257be..453077f6d 100644
28--- a/glib/gdatetime.c
29+++ b/glib/gdatetime.c
30@@ -126,7 +126,7 @@ struct _GDateTime
31 /* 1 is 0001-01-01 in Proleptic Gregorian */
32 gint32 days;
33
34- volatile gint ref_count;
35+ gint ref_count; /* (atomic) */
36 };
37
38 /* Time conversion {{{1 */
39diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
40index 9d0215331..bbe638b74 100644
41--- a/glib/gkeyfile.c
42+++ b/glib/gkeyfile.c
43@@ -512,7 +512,7 @@ struct _GKeyFile
44
45 gchar **locales;
46
47- volatile gint ref_count;
48+ gint ref_count; /* (atomic) */
49 };
50
51 typedef struct _GKeyFileKeyValuePair GKeyFileKeyValuePair;
52diff --git a/glib/gmain.c b/glib/gmain.c
53index 772b8ecfc..9c5f0ef1e 100644
54--- a/glib/gmain.c
55+++ b/glib/gmain.c
56@@ -272,7 +272,7 @@ struct _GMainContext
57 guint owner_count;
58 GSList *waiters;
59
60- volatile gint ref_count;
61+ gint ref_count; /* (atomic) */
62
63 GHashTable *sources; /* guint -> GSource */
64
65@@ -303,7 +303,7 @@ struct _GMainContext
66
67 struct _GSourceCallback
68 {
69- volatile gint ref_count;
70+ gint ref_count; /* (atomic) */
71 GSourceFunc func;
72 gpointer data;
73 GDestroyNotify notify;
74@@ -313,7 +313,7 @@ struct _GMainLoop
75 {
76 GMainContext *context;
77 gboolean is_running; /* (atomic) */
78- volatile gint ref_count;
79+ gint ref_count; /* (atomic) */
80 };
81
82 struct _GTimeoutSource
83@@ -4749,7 +4749,7 @@ g_main_context_get_poll_func (GMainContext *context)
84 *
85 * |[<!-- language="C" -->
86 * #define NUM_TASKS 10
87- * static volatile gint tasks_remaining = NUM_TASKS;
88+ * static gint tasks_remaining = NUM_TASKS; // (atomic)
89 * ...
90 *
91 * while (g_atomic_int_get (&tasks_remaining) != 0)
92diff --git a/glib/gmarkup.c b/glib/gmarkup.c
93index ba4dfd2e4..b8327fb6d 100644
94--- a/glib/gmarkup.c
95+++ b/glib/gmarkup.c
96@@ -119,7 +119,7 @@ struct _GMarkupParseContext
97 {
98 const GMarkupParser *parser;
99
100- volatile gint ref_count;
101+ gint ref_count; /* (atomic) */
102
103 GMarkupParseFlags flags;
104
105diff --git a/glib/gregex.c b/glib/gregex.c
106index 52416bbb9..5e6ddfb46 100644
107--- a/glib/gregex.c
108+++ b/glib/gregex.c
109@@ -203,7 +203,7 @@ G_STATIC_ASSERT (G_REGEX_RAW == PCRE_UTF8);
110
111 struct _GMatchInfo
112 {
113- volatile gint ref_count; /* the ref count */
114+ gint ref_count; /* the ref count (atomic) */
115 GRegex *regex; /* the regex */
116 GRegexMatchFlags match_opts; /* options used at match time on the regex */
117 gint matches; /* number of matching sub patterns */
118@@ -218,7 +218,7 @@ struct _GMatchInfo
119
120 struct _GRegex
121 {
122- volatile gint ref_count; /* the ref count for the immutable part */
123+ gint ref_count; /* the ref count for the immutable part (atomic) */
124 gchar *pattern; /* the pattern */
125 pcre *pcre_re; /* compiled form of the pattern */
126 GRegexCompileFlags compile_opts; /* options used at compile time on the pattern */
127@@ -1300,7 +1300,7 @@ g_regex_new (const gchar *pattern,
128 pcre *re;
129 const gchar *errmsg;
130 gboolean optimize = FALSE;
131- static volatile gsize initialised = 0;
132+ static gsize initialised = 0;
133
134 g_return_val_if_fail (pattern != NULL, NULL);
135 g_return_val_if_fail (error == NULL || *error == NULL, NULL);
136diff --git a/glib/gthread.c b/glib/gthread.c
137index 53f3a0848..612a9739f 100644
138--- a/glib/gthread.c
139+++ b/glib/gthread.c
140@@ -513,7 +513,7 @@ static GMutex g_once_mutex;
141 static GCond g_once_cond;
142 static GSList *g_once_init_list = NULL;
143
144-static volatile guint g_thread_n_created_counter = 0;
145+static guint g_thread_n_created_counter = 0; /* (atomic) */
146
147 static void g_thread_cleanup (gpointer data);
148 static GPrivate g_thread_specific_private = G_PRIVATE_INIT (g_thread_cleanup);
149@@ -694,7 +694,7 @@ g_once_impl (GOnce *once,
150 gboolean
151 (g_once_init_enter) (volatile void *location)
152 {
153- volatile gsize *value_location = location;
154+ gsize *value_location = (gsize *) location;
155 gboolean need_init = FALSE;
156 g_mutex_lock (&g_once_mutex);
157 if (g_atomic_pointer_get (value_location) == 0)
158@@ -731,7 +731,7 @@ void
159 (g_once_init_leave) (volatile void *location,
160 gsize result)
161 {
162- volatile gsize *value_location = location;
163+ gsize *value_location = (gsize *) location;
164
165 g_return_if_fail (g_atomic_pointer_get (value_location) == 0);
166 g_return_if_fail (result != 0);
167--
1682.30.1
169
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0016-gobject-Drop-unnecessary-volatile-qualifiers-from-in.patch b/meta/recipes-core/glib-2.0/glib-2.0/0016-gobject-Drop-unnecessary-volatile-qualifiers-from-in.patch
new file mode 100644
index 0000000000..8111b3b51d
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0016-gobject-Drop-unnecessary-volatile-qualifiers-from-in.patch
@@ -0,0 +1,126 @@
1From 08d04d0428cc26935a2d42083f1710432465c98a Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:42:43 +0000
4Subject: [PATCH 16/29] gobject: Drop unnecessary volatile qualifiers from
5 internal variables
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10These variables were already (correctly) accessed atomically. The
11`volatile` qualifier doesn’t help with that.
12
13Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
14
15Helps: #600
16Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
17---
18 gobject/gclosure.c | 2 +-
19 gobject/gclosure.h | 20 ++++++++++----------
20 gobject/gobject.c | 4 ++--
21 gobject/gtype.c | 10 +++++-----
22 4 files changed, 18 insertions(+), 18 deletions(-)
23
24diff --git a/gobject/gclosure.c b/gobject/gclosure.c
25index 1d1f2f48a..6d41e6d8a 100644
26--- a/gobject/gclosure.c
27+++ b/gobject/gclosure.c
28@@ -98,7 +98,7 @@
29
30 typedef union {
31 GClosure closure;
32- volatile gint vint;
33+ gint vint;
34 } ClosureInt;
35
36 #define CHANGE_FIELD(_closure, _field, _OP, _value, _must_set, _SET_OLD, _SET_NEW) \
37diff --git a/gobject/gclosure.h b/gobject/gclosure.h
38index a0f91f538..884e403a8 100644
39--- a/gobject/gclosure.h
40+++ b/gobject/gclosure.h
41@@ -175,20 +175,20 @@ struct _GClosureNotifyData
42 struct _GClosure
43 {
44 /*< private >*/
45- volatile guint ref_count : 15;
46+ guint ref_count : 15; /* (atomic) */
47 /* meta_marshal is not used anymore but must be zero for historical reasons
48 as it was exposed in the G_CLOSURE_N_NOTIFIERS macro */
49- volatile guint meta_marshal_nouse : 1;
50- volatile guint n_guards : 1;
51- volatile guint n_fnotifiers : 2; /* finalization notifiers */
52- volatile guint n_inotifiers : 8; /* invalidation notifiers */
53- volatile guint in_inotify : 1;
54- volatile guint floating : 1;
55+ guint meta_marshal_nouse : 1; /* (atomic) */
56+ guint n_guards : 1; /* (atomic) */
57+ guint n_fnotifiers : 2; /* finalization notifiers (atomic) */
58+ guint n_inotifiers : 8; /* invalidation notifiers (atomic) */
59+ guint in_inotify : 1; /* (atomic) */
60+ guint floating : 1; /* (atomic) */
61 /*< protected >*/
62- volatile guint derivative_flag : 1;
63+ guint derivative_flag : 1; /* (atomic) */
64 /*< public >*/
65- volatile guint in_marshal : 1;
66- volatile guint is_invalid : 1;
67+ guint in_marshal : 1; /* (atomic) */
68+ guint is_invalid : 1; /* (atomic) */
69
70 /*< private >*/ void (*marshal) (GClosure *closure,
71 GValue /*out*/ *return_value,
72diff --git a/gobject/gobject.c b/gobject/gobject.c
73index 6e9c44a1e..a3a32be9f 100644
74--- a/gobject/gobject.c
75+++ b/gobject/gobject.c
76@@ -174,9 +174,9 @@ typedef struct
77 GTypeInstance g_type_instance;
78
79 /*< private >*/
80- volatile guint ref_count;
81+ guint ref_count; /* (atomic) */
82 #ifdef HAVE_OPTIONAL_FLAGS
83- volatile guint optional_flags;
84+ guint optional_flags; /* (atomic) */
85 #endif
86 GData *qdata;
87 } GObjectReal;
88diff --git a/gobject/gtype.c b/gobject/gtype.c
89index 51dad7690..be5989a3e 100644
90--- a/gobject/gtype.c
91+++ b/gobject/gtype.c
92@@ -221,9 +221,9 @@ typedef enum
93 /* --- structures --- */
94 struct _TypeNode
95 {
96- guint volatile ref_count;
97+ guint ref_count; /* (atomic) */
98 #ifdef G_ENABLE_DEBUG
99- guint volatile instance_count;
100+ guint instance_count; /* (atomic) */
101 #endif
102 GTypePlugin *plugin;
103 guint n_children; /* writable with lock */
104@@ -233,7 +233,7 @@ struct _TypeNode
105 guint is_instantiatable : 1;
106 guint mutatable_check_cache : 1; /* combines some common path checks */
107 GType *children; /* writable with lock */
108- TypeData * volatile data;
109+ TypeData *data;
110 GQuark qname;
111 GData *global_gdata;
112 union {
113@@ -569,8 +569,8 @@ type_node_new_W (TypeNode *pnode,
114 }
115
116 static inline IFaceEntry*
117-lookup_iface_entry_I (volatile IFaceEntries *entries,
118- TypeNode *iface_node)
119+lookup_iface_entry_I (IFaceEntries *entries,
120+ TypeNode *iface_node)
121 {
122 guint8 *offsets;
123 guint offset_index;
124--
1252.30.1
126
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0017-gmessages-Drop-unnecessary-volatile-qualifiers-from-.patch b/meta/recipes-core/glib-2.0/glib-2.0/0017-gmessages-Drop-unnecessary-volatile-qualifiers-from-.patch
new file mode 100644
index 0000000000..02816a887c
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0017-gmessages-Drop-unnecessary-volatile-qualifiers-from-.patch
@@ -0,0 +1,44 @@
1From eee7e3c6688f2f1ee9beed5d6d209973c1df387e Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 19:14:25 +0000
4Subject: [PATCH 17/29] gmessages: Drop unnecessary volatile qualifiers from
5 macro variables
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10It’s not necessary and provides no thread safety guarantees.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 glib/gmessages.h | 4 ++--
18 1 file changed, 2 insertions(+), 2 deletions(-)
19
20diff --git a/glib/gmessages.h b/glib/gmessages.h
21index 6a28443b4..2e3650baf 100644
22--- a/glib/gmessages.h
23+++ b/glib/gmessages.h
24@@ -478,7 +478,7 @@ g_debug (const gchar *format,
25 #if defined(G_HAVE_ISO_VARARGS) && !G_ANALYZER_ANALYZING
26 #define g_warning_once(...) \
27 G_STMT_START { \
28- static volatile int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; \
29+ static int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; /* (atomic) */ \
30 if (g_atomic_int_compare_and_exchange (&G_PASTE (_GWarningOnceBoolean, __LINE__), \
31 0, 1)) \
32 g_warning (__VA_ARGS__); \
33@@ -487,7 +487,7 @@ g_debug (const gchar *format,
34 #elif defined(G_HAVE_GNUC_VARARGS) && !G_ANALYZER_ANALYZING
35 #define g_warning_once(format...) \
36 G_STMT_START { \
37- static volatile int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; \
38+ static int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; /* (atomic) */ \
39 if (g_atomic_int_compare_and_exchange (&G_PASTE (_GWarningOnceBoolean, __LINE__), \
40 0, 1)) \
41 g_warning (format); \
42--
432.30.1
44
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0018-gtypes-Drop-volatile-qualifier-from-gatomicrefcount.patch b/meta/recipes-core/glib-2.0/glib-2.0/0018-gtypes-Drop-volatile-qualifier-from-gatomicrefcount.patch
new file mode 100644
index 0000000000..50cb3c470e
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0018-gtypes-Drop-volatile-qualifier-from-gatomicrefcount.patch
@@ -0,0 +1,35 @@
1From 8a87069ff42a0631dce153701cb2ec5e343a958c Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 19:16:30 +0000
4Subject: [PATCH 18/29] gtypes: Drop volatile qualifier from gatomicrefcount
5
6This is technically an API break, but since the type is meant to be
7opaque (third party code is not meant to treat it like an integer) it
8should not cause problems.
9
10Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
11
12Helps: #600
13Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
14---
15 glib/gtypes.h | 4 ++--
16 1 file changed, 2 insertions(+), 2 deletions(-)
17
18diff --git a/glib/gtypes.h b/glib/gtypes.h
19index 23c5a1295..2c4825582 100644
20--- a/glib/gtypes.h
21+++ b/glib/gtypes.h
22@@ -550,8 +550,8 @@ struct _GTimeVal
23 glong tv_usec;
24 } GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime);
25
26-typedef gint grefcount;
27-typedef volatile gint gatomicrefcount;
28+typedef gint grefcount;
29+typedef gint gatomicrefcount; /* should be accessed only using atomics */
30
31 G_END_DECLS
32
33--
342.30.1
35
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0019-gatomicarray-Drop-volatile-qualifier-from-GAtomicArr.patch b/meta/recipes-core/glib-2.0/glib-2.0/0019-gatomicarray-Drop-volatile-qualifier-from-GAtomicArr.patch
new file mode 100644
index 0000000000..be3211664a
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0019-gatomicarray-Drop-volatile-qualifier-from-GAtomicArr.patch
@@ -0,0 +1,44 @@
1From 46bae4f18dfec8fedda82648091752d270b2dff8 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 19:19:20 +0000
4Subject: [PATCH 19/29] gatomicarray: Drop volatile qualifier from GAtomicArray
5 API
6
7This is an API break, but it should not affect third party code since
8that code should not be interacting with the `data` member in a way that
9invokes its `volatile` qualifier (such as copying to an intermediate
10variable).
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 gobject/gatomicarray.h | 4 ++--
18 1 file changed, 2 insertions(+), 2 deletions(-)
19
20diff --git a/gobject/gatomicarray.h b/gobject/gatomicarray.h
21index 9550fa396..89043c5e4 100644
22--- a/gobject/gatomicarray.h
23+++ b/gobject/gatomicarray.h
24@@ -29,7 +29,7 @@ G_BEGIN_DECLS
25
26 typedef struct _GAtomicArray GAtomicArray;
27 struct _GAtomicArray {
28- volatile gpointer data; /* elements - atomic */
29+ gpointer data; /* elements - atomic */
30 };
31
32 void _g_atomic_array_init (GAtomicArray *array);
33@@ -42,7 +42,7 @@ void _g_atomic_array_update (GAtomicArray *array,
34 #define G_ATOMIC_ARRAY_GET_LOCKED(_array, _type) ((_type *)((_array)->data))
35
36 #define G_ATOMIC_ARRAY_DO_TRANSACTION(_array, _type, _C_) G_STMT_START { \
37- volatile gpointer *_datap = &(_array)->data; \
38+ gpointer *_datap = &(_array)->data; \
39 _type *transaction_data, *__check; \
40 \
41 __check = g_atomic_pointer_get (_datap); \
42--
432.30.1
44
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0020-gobject-Drop-volatile-qualifier-from-GObject.ref_cou.patch b/meta/recipes-core/glib-2.0/glib-2.0/0020-gobject-Drop-volatile-qualifier-from-GObject.ref_cou.patch
new file mode 100644
index 0000000000..ae024a9af4
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0020-gobject-Drop-volatile-qualifier-from-GObject.ref_cou.patch
@@ -0,0 +1,33 @@
1From 334f6953364680ddc6c0d3da13fda1d92bf5379d Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 19:21:07 +0000
4Subject: [PATCH 20/29] gobject: Drop volatile qualifier from GObject.ref_count
5
6This is an API break, but no third party code should be touching
7`GObject.ref_count`, let alone in a way which would be changed by the
8removal of the `volatile` qualifier.
9
10Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
11
12Helps: #600
13Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
14---
15 gobject/gobject.h | 2 +-
16 1 file changed, 1 insertion(+), 1 deletion(-)
17
18diff --git a/gobject/gobject.h b/gobject/gobject.h
19index 7f55e1976..a84c183f8 100644
20--- a/gobject/gobject.h
21+++ b/gobject/gobject.h
22@@ -247,7 +247,7 @@ struct _GObject
23 GTypeInstance g_type_instance;
24
25 /*< private >*/
26- volatile guint ref_count;
27+ guint ref_count; /* (atomic) */
28 GData *qdata;
29 };
30 /**
31--
322.30.1
33
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0021-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch b/meta/recipes-core/glib-2.0/glib-2.0/0021-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
new file mode 100644
index 0000000000..b8ed99ce15
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0021-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
@@ -0,0 +1,51 @@
1From 8a112c3c6e5fe6838ee29eec7caa62ba32d9bc40 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 19:22:49 +0000
4Subject: [PATCH 21/29] tests: Drop unnecessary volatile qualifiers from tests
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9These variables were already (correctly) accessed atomically. The
10`volatile` qualifier doesn’t help with that.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 gobject/tests/qdata.c | 2 +-
18 gobject/tests/threadtests.c | 4 ++--
19 2 files changed, 3 insertions(+), 3 deletions(-)
20
21diff --git a/gobject/tests/qdata.c b/gobject/tests/qdata.c
22index 528bdc68e..7d46efb15 100644
23--- a/gobject/tests/qdata.c
24+++ b/gobject/tests/qdata.c
25@@ -17,7 +17,7 @@ gboolean fail;
26 #define ROUNDS 10000
27
28 GObject *object;
29-volatile gint bucket[THREADS];
30+gint bucket[THREADS]; /* accessed from multiple threads, but should never be contested due to the sequence of thread operations */
31
32 static gpointer
33 thread_func (gpointer data)
34diff --git a/gobject/tests/threadtests.c b/gobject/tests/threadtests.c
35index e341a9d67..b6f9e17fa 100644
36--- a/gobject/tests/threadtests.c
37+++ b/gobject/tests/threadtests.c
38@@ -27,8 +27,8 @@
39 #include <glib.h>
40 #include <glib-object.h>
41
42-static volatile int mtsafe_call_counter = 0; /* multi thread safe call counter */
43-static int unsafe_call_counter = 0; /* single-threaded call counter */
44+static int mtsafe_call_counter = 0; /* multi thread safe call counter, must be accessed atomically */
45+static int unsafe_call_counter = 0; /* single-threaded call counter */
46 static GCond sync_cond;
47 static GMutex sync_mutex;
48
49--
502.30.1
51
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0022-build-Drop-unnecessary-volatile-qualifiers-from-conf.patch b/meta/recipes-core/glib-2.0/glib-2.0/0022-build-Drop-unnecessary-volatile-qualifiers-from-conf.patch
new file mode 100644
index 0000000000..5da509d178
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0022-build-Drop-unnecessary-volatile-qualifiers-from-conf.patch
@@ -0,0 +1,38 @@
1From daf90bfa99fc02a253d538c65fbaa12f2e6c1c45 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 19:23:18 +0000
4Subject: [PATCH 22/29] build: Drop unnecessary volatile qualifiers from
5 configure tests
6
7Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
8
9Helps: #600
10Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
11---
12 meson.build | 3 ++-
13 1 file changed, 2 insertions(+), 1 deletion(-)
14
15diff --git a/meson.build b/meson.build
16index e0b308a25..ad7f887fb 100644
17--- a/meson.build
18+++ b/meson.build
19@@ -1773,7 +1773,7 @@ endforeach
20 # that then to silently fall back on emulated atomic ops just because
21 # the user had the wrong build environment.
22 atomictest = '''int main() {
23- volatile int atomic = 2;
24+ int atomic = 2;
25 __sync_bool_compare_and_swap (&atomic, 2, 3);
26 return 0;
27 }
28@@ -1883,6 +1883,7 @@ endif
29
30 # FIXME: we should make it print the result and always return 0, so that
31 # the output in meson shows up as green
32+# volatile is needed here to avoid optimisations in the test
33 stack_grows_check_prog = '''
34 volatile int *a = 0, *b = 0;
35 void f (int i) {
36--
372.30.1
38
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0023-gdbusprivate-Avoid-a-warning-about-a-statement-with-.patch b/meta/recipes-core/glib-2.0/glib-2.0/0023-gdbusprivate-Avoid-a-warning-about-a-statement-with-.patch
new file mode 100644
index 0000000000..012f9ca87a
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0023-gdbusprivate-Avoid-a-warning-about-a-statement-with-.patch
@@ -0,0 +1,33 @@
1From 0604f5858259c32744e6fc912ed4feb308651a3a Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Mon, 16 Nov 2020 14:47:23 +0000
4Subject: [PATCH 23/29] gdbusprivate: Avoid a warning about a statement with no
5 effect
6
7Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
8Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
9---
10 gio/gdbusprivate.c | 5 ++---
11 1 file changed, 2 insertions(+), 3 deletions(-)
12
13diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
14index 99b37f3eb..4e42c1a4d 100644
15--- a/gio/gdbusprivate.c
16+++ b/gio/gdbusprivate.c
17@@ -1945,11 +1945,10 @@ _g_dbus_initialize (void)
18
19 if (g_once_init_enter (&initialized))
20 {
21- GQuark g_dbus_error_domain;
22 const gchar *debug;
23
24- g_dbus_error_domain = G_DBUS_ERROR;
25- (g_dbus_error_domain); /* To avoid -Wunused-but-set-variable */
26+ /* Ensure the domain is registered. */
27+ g_dbus_error_quark ();
28
29 debug = g_getenv ("G_DBUS_DEBUG");
30 if (debug != NULL)
31--
322.30.1
33
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0024-tests-Add-comment-to-volatile-atomic-tests.patch b/meta/recipes-core/glib-2.0/glib-2.0/0024-tests-Add-comment-to-volatile-atomic-tests.patch
new file mode 100644
index 0000000000..7350803c6f
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0024-tests-Add-comment-to-volatile-atomic-tests.patch
@@ -0,0 +1,49 @@
1From 2d03f99ae4de394cac0690717d96c2d884ccdae2 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Mon, 16 Nov 2020 14:47:47 +0000
4Subject: [PATCH 24/29] tests: Add comment to volatile atomic tests
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9`volatile` should not be used to indicate atomic variables, and we
10shouldn’t encourage its use. Keep the tests, since they check that we
11don’t emit warnings when built against incorrect old code which uses
12`volatile`. But add a comment to stop copy/paste use of `volatile`
13in the future.
14
15Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
16
17Helps: #600
18Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
19---
20 glib/tests/atomic.c | 6 ++++++
21 1 file changed, 6 insertions(+)
22
23diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c
24index 7d2459f3a..14e6e454e 100644
25--- a/glib/tests/atomic.c
26+++ b/glib/tests/atomic.c
27@@ -94,6 +94,9 @@ test_types (void)
28 res = g_atomic_pointer_compare_and_exchange (&vp_str, NULL, str);
29 g_assert_true (res);
30
31+ /* Note that atomic variables should almost certainly not be marked as
32+ * `volatile` — see http://isvolatileusefulwiththreads.in/c/. This test exists
33+ * to make sure that we don’t warn when built against older third party code. */
34 g_atomic_pointer_set (&vp_str_vol, NULL);
35 res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, str);
36 g_assert_true (res);
37@@ -210,6 +213,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
38 res = g_atomic_pointer_compare_and_exchange (&vp_str, NULL, (char *) str);
39 g_assert_true (res);
40
41+ /* Note that atomic variables should almost certainly not be marked as
42+ * `volatile` — see http://isvolatileusefulwiththreads.in/c/. This test exists
43+ * to make sure that we don’t warn when built against older third party code. */
44 g_atomic_pointer_set (&vp_str_vol, NULL);
45 res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, (char *) str);
46 g_assert_true (res);
47--
482.30.1
49
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
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0026-gtype-Fix-some-typos-in-comments.patch b/meta/recipes-core/glib-2.0/glib-2.0/0026-gtype-Fix-some-typos-in-comments.patch
new file mode 100644
index 0000000000..7090a12a8b
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0026-gtype-Fix-some-typos-in-comments.patch
@@ -0,0 +1,47 @@
1From 041dd8b70bd14b041d6a495492eb7a5fc7568bb7 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Mon, 16 Nov 2020 16:47:54 +0000
4Subject: [PATCH 26/29] gtype: Fix some typos in comments
5
6Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
7Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
8---
9 gobject/gtype.c | 8 ++++----
10 1 file changed, 4 insertions(+), 4 deletions(-)
11
12diff --git a/gobject/gtype.c b/gobject/gtype.c
13index be5989a3e..ae1af8a05 100644
14--- a/gobject/gtype.c
15+++ b/gobject/gtype.c
16@@ -2290,7 +2290,7 @@ type_class_init_Wm (TypeNode *node,
17 * inherited interfaces are already init_state == INITIALIZED, because
18 * they either got setup in the above base_init loop, or during
19 * class_init from within type_add_interface_Wm() for this or
20- * an anchestor type.
21+ * an ancestor type.
22 */
23 i = 0;
24 while ((entries = CLASSED_NODE_IFACES_ENTRIES_LOCKED (node)) != NULL)
25@@ -3462,7 +3462,7 @@ g_type_depth (GType type)
26 * be used to determine the types and order in which the leaf type is
27 * descended from the root type.
28 *
29- * Returns: immediate child of @root_type and anchestor of @leaf_type
30+ * Returns: immediate child of @root_type and ancestor of @leaf_type
31 */
32 GType
33 g_type_next_base (GType type,
34@@ -3549,8 +3549,8 @@ type_node_conforms_to_U (TypeNode *node,
35
36 /**
37 * g_type_is_a:
38- * @type: type to check anchestry for
39- * @is_a_type: possible anchestor of @type or interface that @type
40+ * @type: type to check ancestry for
41+ * @is_a_type: possible ancestor of @type or interface that @type
42 * could conform to
43 *
44 * If @is_a_type is a derivable type, check whether @type is a
45--
462.30.1
47
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0027-gtype-Add-some-missing-atomic-accesses-to-init_state.patch b/meta/recipes-core/glib-2.0/glib-2.0/0027-gtype-Add-some-missing-atomic-accesses-to-init_state.patch
new file mode 100644
index 0000000000..9c4e45ff41
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0027-gtype-Add-some-missing-atomic-accesses-to-init_state.patch
@@ -0,0 +1,76 @@
1From 47da8ec5d9a284e07f77c7d59fc8eacf3ebf188a Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Mon, 16 Nov 2020 16:57:22 +0000
4Subject: [PATCH 27/29] gtype: Add some missing atomic accesses to init_state
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Half of the references to `init_state` in `gtype.c` already correctly
10accessed it atomically, but a couple didn’t. Drop the `volatile`
11qualifier from its declaration, as that’s not necessary for atomic
12access.
13
14Note that this is the `init_state` in `TypeData`, *not* the `init_state`
15in `IFaceEntry`.
16
17Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
18
19Helps: #600
20Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
21---
22 gobject/gtype.c | 10 +++++-----
23 1 file changed, 5 insertions(+), 5 deletions(-)
24
25diff --git a/gobject/gtype.c b/gobject/gtype.c
26index ae1af8a05..909faf138 100644
27--- a/gobject/gtype.c
28+++ b/gobject/gtype.c
29@@ -322,7 +322,7 @@ struct _ClassData
30 CommonData common;
31 guint16 class_size;
32 guint16 class_private_size;
33- int volatile init_state; /* atomic - g_type_class_ref reads it unlocked */
34+ int init_state; /* (atomic) - g_type_class_ref reads it unlocked */
35 GBaseInitFunc class_init_base;
36 GBaseFinalizeFunc class_finalize_base;
37 GClassInitFunc class_init;
38@@ -336,7 +336,7 @@ struct _InstanceData
39 CommonData common;
40 guint16 class_size;
41 guint16 class_private_size;
42- int volatile init_state; /* atomic - g_type_class_ref reads it unlocked */
43+ int init_state; /* (atomic) - g_type_class_ref reads it unlocked */
44 GBaseInitFunc class_init_base;
45 GBaseFinalizeFunc class_finalize_base;
46 GClassInitFunc class_init;
47@@ -1415,7 +1415,7 @@ type_node_add_iface_entry_W (TypeNode *node,
48
49 if (parent_entry)
50 {
51- if (node->data && node->data->class.init_state >= BASE_IFACE_INIT)
52+ if (node->data && g_atomic_int_get (&node->data->class.init_state) >= BASE_IFACE_INIT)
53 {
54 entries->entry[i].init_state = INITIALIZED;
55 entries->entry[i].vtable = parent_entry->vtable;
56@@ -1481,7 +1481,7 @@ type_add_interface_Wm (TypeNode *node,
57 */
58 if (node->data)
59 {
60- InitState class_state = node->data->class.init_state;
61+ InitState class_state = g_atomic_int_get (&node->data->class.init_state);
62
63 if (class_state >= BASE_IFACE_INIT)
64 type_iface_vtable_base_init_Wm (iface, node);
65@@ -2175,7 +2175,7 @@ type_class_init_Wm (TypeNode *node,
66 g_assert (node->is_classed && node->data &&
67 node->data->class.class_size &&
68 !node->data->class.class &&
69- node->data->class.init_state == UNINITIALIZED);
70+ g_atomic_int_get (&node->data->class.init_state) == UNINITIALIZED);
71 if (node->data->class.class_private_size)
72 class = g_malloc0 (ALIGN_STRUCT (node->data->class.class_size) + node->data->class.class_private_size);
73 else
74--
752.30.1
76
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0028-gresource-Fix-a-pointer-mismatch-with-an-atomic-load.patch b/meta/recipes-core/glib-2.0/glib-2.0/0028-gresource-Fix-a-pointer-mismatch-with-an-atomic-load.patch
new file mode 100644
index 0000000000..e03fac19f4
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0028-gresource-Fix-a-pointer-mismatch-with-an-atomic-load.patch
@@ -0,0 +1,29 @@
1From 7d417f8406b8fa32a25659120738d22be6a1b482 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Mon, 16 Nov 2020 17:17:21 +0000
4Subject: [PATCH 28/29] gresource: Fix a pointer mismatch with an atomic load
5
6This squashes a warning when compiling with Clang.
7
8Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
9Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
10---
11 gio/gresource.c | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/gio/gresource.c b/gio/gresource.c
15index 79a49d33d..b495d12ac 100644
16--- a/gio/gresource.c
17+++ b/gio/gresource.c
18@@ -1398,7 +1398,7 @@ register_lazy_static_resources (void)
19 void
20 g_static_resource_init (GStaticResource *static_resource)
21 {
22- gpointer next;
23+ GStaticResource *next;
24
25 do
26 {
27--
282.30.1
29
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/0029-docs-Document-not-to-use-volatile-qualifiers.patch b/meta/recipes-core/glib-2.0/glib-2.0/0029-docs-Document-not-to-use-volatile-qualifiers.patch
new file mode 100644
index 0000000000..3311ad65d6
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/0029-docs-Document-not-to-use-volatile-qualifiers.patch
@@ -0,0 +1,258 @@
1From 83e48d8ac1fee98059e2305d8909dca26190bddc Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Tue, 17 Nov 2020 10:15:15 +0000
4Subject: [PATCH 29/29] docs: Document not to use `volatile` qualifiers
5
6Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
7
8Fixes: #600
9Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
10---
11 gio/gdbusconnection.c | 12 ++++++++---
12 gio/gdbuserror.c | 3 +++
13 glib/gatomic.c | 48 +++++++++++++++++++++++++++++++++++++++++++
14 glib/gthread.c | 6 ++++++
15 4 files changed, 66 insertions(+), 3 deletions(-)
16
17diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
18index 91c365e80..65939a4d2 100644
19--- a/gio/gdbusconnection.c
20+++ b/gio/gdbusconnection.c
21@@ -1708,7 +1708,9 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
22 * will be assigned by @connection and set on @message via
23 * g_dbus_message_set_serial(). If @out_serial is not %NULL, then the
24 * serial number used will be written to this location prior to
25- * submitting the message to the underlying transport.
26+ * submitting the message to the underlying transport. While it has a `volatile`
27+ * qualifier, this is a historical artifact and the argument passed to it should
28+ * not be `volatile`.
29 *
30 * If @connection is closed then the operation will fail with
31 * %G_IO_ERROR_CLOSED. If @message is not well-formed,
32@@ -1979,7 +1981,9 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect
33 * will be assigned by @connection and set on @message via
34 * g_dbus_message_set_serial(). If @out_serial is not %NULL, then the
35 * serial number used will be written to this location prior to
36- * submitting the message to the underlying transport.
37+ * submitting the message to the underlying transport. While it has a `volatile`
38+ * qualifier, this is a historical artifact and the argument passed to it should
39+ * not be `volatile`.
40 *
41 * If @connection is closed then the operation will fail with
42 * %G_IO_ERROR_CLOSED. If @cancellable is canceled, the operation will
43@@ -2105,7 +2109,9 @@ send_message_with_reply_sync_cb (GDBusConnection *connection,
44 * will be assigned by @connection and set on @message via
45 * g_dbus_message_set_serial(). If @out_serial is not %NULL, then the
46 * serial number used will be written to this location prior to
47- * submitting the message to the underlying transport.
48+ * submitting the message to the underlying transport. While it has a `volatile`
49+ * qualifier, this is a historical artifact and the argument passed to it should
50+ * not be `volatile`.
51 *
52 * If @connection is closed then the operation will fail with
53 * %G_IO_ERROR_CLOSED. If @cancellable is canceled, the operation will
54diff --git a/gio/gdbuserror.c b/gio/gdbuserror.c
55index b03a33f27..4ad97bb6e 100644
56--- a/gio/gdbuserror.c
57+++ b/gio/gdbuserror.c
58@@ -177,6 +177,9 @@ g_dbus_error_quark (void)
59 *
60 * Helper function for associating a #GError error domain with D-Bus error names.
61 *
62+ * While @quark_volatile has a `volatile` qualifier, this is a historical
63+ * artifact and the argument passed to it should not be `volatile`.
64+ *
65 * Since: 2.26
66 */
67 void
68diff --git a/glib/gatomic.c b/glib/gatomic.c
69index 67f5ba6b4..0bc67aa35 100644
70--- a/glib/gatomic.c
71+++ b/glib/gatomic.c
72@@ -105,6 +105,9 @@
73 * This call acts as a full compiler and hardware
74 * memory barrier (before the get).
75 *
76+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
77+ * the pointer passed to it should not be `volatile`.
78+ *
79 * Returns: the value of the integer
80 *
81 * Since: 2.4
82@@ -125,6 +128,9 @@ gint
83 * This call acts as a full compiler and hardware
84 * memory barrier (after the set).
85 *
86+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
87+ * the pointer passed to it should not be `volatile`.
88+ *
89 * Since: 2.4
90 */
91 void
92@@ -144,6 +150,9 @@ void
93 *
94 * This call acts as a full compiler and hardware memory barrier.
95 *
96+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
97+ * the pointer passed to it should not be `volatile`.
98+ *
99 * Since: 2.4
100 **/
101 void
102@@ -163,6 +172,9 @@ void
103 *
104 * This call acts as a full compiler and hardware memory barrier.
105 *
106+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
107+ * the pointer passed to it should not be `volatile`.
108+ *
109 * Returns: %TRUE if the resultant value is zero
110 *
111 * Since: 2.4
112@@ -189,6 +201,9 @@ gboolean
113 *
114 * This call acts as a full compiler and hardware memory barrier.
115 *
116+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
117+ * the pointer passed to it should not be `volatile`.
118+ *
119 * Returns: %TRUE if the exchange took place
120 *
121 * Since: 2.4
122@@ -216,6 +231,9 @@ gboolean
123 * Before version 2.30, this function did not return a value
124 * (but g_atomic_int_exchange_and_add() did, and had the same meaning).
125 *
126+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
127+ * the pointer passed to it should not be `volatile`.
128+ *
129 * Returns: the value of @atomic before the add, signed
130 *
131 * Since: 2.4
132@@ -240,6 +258,9 @@ gint
133 * Think of this operation as an atomic version of
134 * `{ tmp = *atomic; *atomic &= val; return tmp; }`.
135 *
136+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
137+ * the pointer passed to it should not be `volatile`.
138+ *
139 * Returns: the value of @atomic before the operation, unsigned
140 *
141 * Since: 2.30
142@@ -264,6 +285,9 @@ guint
143 *
144 * This call acts as a full compiler and hardware memory barrier.
145 *
146+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
147+ * the pointer passed to it should not be `volatile`.
148+ *
149 * Returns: the value of @atomic before the operation, unsigned
150 *
151 * Since: 2.30
152@@ -288,6 +312,9 @@ guint
153 *
154 * This call acts as a full compiler and hardware memory barrier.
155 *
156+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
157+ * the pointer passed to it should not be `volatile`.
158+ *
159 * Returns: the value of @atomic before the operation, unsigned
160 *
161 * Since: 2.30
162@@ -309,6 +336,9 @@ guint
163 * This call acts as a full compiler and hardware
164 * memory barrier (before the get).
165 *
166+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
167+ * the pointer passed to it should not be `volatile`.
168+ *
169 * Returns: the value of the pointer
170 *
171 * Since: 2.4
172@@ -329,6 +359,9 @@ gpointer
173 * This call acts as a full compiler and hardware
174 * memory barrier (after the set).
175 *
176+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
177+ * the pointer passed to it should not be `volatile`.
178+ *
179 * Since: 2.4
180 **/
181 void
182@@ -354,6 +387,9 @@ void
183 *
184 * This call acts as a full compiler and hardware memory barrier.
185 *
186+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
187+ * the pointer passed to it should not be `volatile`.
188+ *
189 * Returns: %TRUE if the exchange took place
190 *
191 * Since: 2.4
192@@ -379,6 +415,9 @@ gboolean
193 *
194 * This call acts as a full compiler and hardware memory barrier.
195 *
196+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
197+ * the pointer passed to it should not be `volatile`.
198+ *
199 * Returns: the value of @atomic before the add, signed
200 *
201 * Since: 2.30
202@@ -403,6 +442,9 @@ gssize
203 *
204 * This call acts as a full compiler and hardware memory barrier.
205 *
206+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
207+ * the pointer passed to it should not be `volatile`.
208+ *
209 * Returns: the value of @atomic before the operation, unsigned
210 *
211 * Since: 2.30
212@@ -427,6 +469,9 @@ gsize
213 *
214 * This call acts as a full compiler and hardware memory barrier.
215 *
216+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
217+ * the pointer passed to it should not be `volatile`.
218+ *
219 * Returns: the value of @atomic before the operation, unsigned
220 *
221 * Since: 2.30
222@@ -451,6 +496,9 @@ gsize
223 *
224 * This call acts as a full compiler and hardware memory barrier.
225 *
226+ * While @atomic has a `volatile` qualifier, this is a historical artifact and
227+ * the pointer passed to it should not be `volatile`.
228+ *
229 * Returns: the value of @atomic before the operation, unsigned
230 *
231 * Since: 2.30
232diff --git a/glib/gthread.c b/glib/gthread.c
233index 612a9739f..29216d7fd 100644
234--- a/glib/gthread.c
235+++ b/glib/gthread.c
236@@ -686,6 +686,9 @@ g_once_impl (GOnce *once,
237 * // use initialization_value here
238 * ]|
239 *
240+ * While @location has a `volatile` qualifier, this is a historical artifact and
241+ * the pointer passed to it should not be `volatile`.
242+ *
243 * Returns: %TRUE if the initialization section should be entered,
244 * %FALSE and blocks otherwise
245 *
246@@ -725,6 +728,9 @@ gboolean
247 * releases concurrent threads blocking in g_once_init_enter() on this
248 * initialization variable.
249 *
250+ * While @location has a `volatile` qualifier, this is a historical artifact and
251+ * the pointer passed to it should not be `volatile`.
252+ *
253 * Since: 2.14
254 */
255 void
256--
2572.30.1
258
diff --git a/meta/recipes-core/glib-2.0/glib-2.0_2.66.7.bb b/meta/recipes-core/glib-2.0/glib-2.0_2.66.7.bb
index 4176dbd207..3909b76ddf 100644
--- a/meta/recipes-core/glib-2.0/glib-2.0_2.66.7.bb
+++ b/meta/recipes-core/glib-2.0/glib-2.0_2.66.7.bb
@@ -19,7 +19,37 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
19 file://0001-gio-tests-codegen.py-bump-timeout-to-100-seconds.patch \ 19 file://0001-gio-tests-codegen.py-bump-timeout-to-100-seconds.patch \
20 file://0001-tests-codegen.py-removing-unecessary-print-statement.patch \ 20 file://0001-tests-codegen.py-removing-unecessary-print-statement.patch \
21 " 21 "
22 22SRC_URI += "\
23 file://0001-gobject-Drop-use-of-volatile-from-get_type-macros.patch \
24 file://0002-tests-Fix-non-atomic-access-to-a-shared-variable.patch \
25 file://0003-tests-Fix-non-atomic-access-to-a-shared-variable.patch \
26 file://0004-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch \
27 file://0005-tests-Fix-non-atomic-access-to-some-shared-variables.patch \
28 file://0006-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch \
29 file://0007-gdbusconnection-Drop-unnecessary-volatile-qualifiers.patch \
30 file://0008-gdbuserror-Drop-unnecessary-volatile-qualifiers-from.patch \
31 file://0009-gio-Drop-unnecessary-volatile-qualifiers-from-intern.patch \
32 file://0010-kqueue-Fix-unlocked-access-to-shared-variable.patch \
33 file://0011-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch \
34 file://0012-tests-Fix-non-atomic-access-to-some-shared-variables.patch \
35 file://0013-gatomic-Drop-unnecessary-volatile-qualifiers-from-in.patch \
36 file://0014-gatomic-Drop-unnecessary-volatile-qualifiers-from-ma.patch \
37 file://0015-glib-Drop-unnecessary-volatile-qualifiers-from-inter.patch \
38 file://0016-gobject-Drop-unnecessary-volatile-qualifiers-from-in.patch \
39 file://0017-gmessages-Drop-unnecessary-volatile-qualifiers-from-.patch \
40 file://0018-gtypes-Drop-volatile-qualifier-from-gatomicrefcount.patch \
41 file://0019-gatomicarray-Drop-volatile-qualifier-from-GAtomicArr.patch \
42 file://0020-gobject-Drop-volatile-qualifier-from-GObject.ref_cou.patch \
43 file://0021-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch \
44 file://0022-build-Drop-unnecessary-volatile-qualifiers-from-conf.patch \
45 file://0023-gdbusprivate-Avoid-a-warning-about-a-statement-with-.patch \
46 file://0024-tests-Add-comment-to-volatile-atomic-tests.patch \
47 file://0025-gthread-Use-g_atomic-primitives-correctly-in-destruc.patch \
48 file://0026-gtype-Fix-some-typos-in-comments.patch \
49 file://0027-gtype-Add-some-missing-atomic-accesses-to-init_state.patch \
50 file://0028-gresource-Fix-a-pointer-mismatch-with-an-atomic-load.patch \
51 file://0029-docs-Document-not-to-use-volatile-qualifiers.patch \
52"
23SRC_URI_append_class-native = " file://relocate-modules.patch" 53SRC_URI_append_class-native = " file://relocate-modules.patch"
24 54
25SRC_URI[sha256sum] = "09f158769f6f26b31074e15b1ac80ec39b13b53102dfae66cfe826fb2cc65502" 55SRC_URI[sha256sum] = "09f158769f6f26b31074e15b1ac80ec39b13b53102dfae66cfe826fb2cc65502"