summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glib-2.0/glib-2.0/0004-tests-Drop-unnecessary-volatile-qualifiers-from-test.patch
blob: 4b7b6f463a7258e76a6dcbce21357cbde1a257cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From 3dda662bebb81666d009635df1055ba5c1e17b52 Mon Sep 17 00:00:00 2001
From: Philip Withnall <pwithnall@endlessos.org>
Date: Wed, 11 Nov 2020 18:16:17 +0000
Subject: [PATCH 04/29] tests: Drop unnecessary volatile qualifiers from tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

These variables were already (correctly) accessed atomically. The
`volatile` qualifier doesn’t help with that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #600
Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
---
 glib/tests/atomic.c      | 4 ++--
 glib/tests/cond.c        | 2 +-
 glib/tests/gwakeuptest.c | 2 +-
 glib/tests/hash.c        | 2 +-
 glib/tests/slice.c       | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c
index 6b6cc7f3e..7d2459f3a 100644
--- a/glib/tests/atomic.c
+++ b/glib/tests/atomic.c
@@ -248,8 +248,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 #define THREADS 10
 #define ROUNDS 10000
 
-volatile gint bucket[THREADS];
-volatile gint atomic;
+gint bucket[THREADS];  /* never contested by threads, not accessed atomically */
+gint atomic;  /* (atomic) */
 
 static gpointer
 thread_func (gpointer data)
diff --git a/glib/tests/cond.c b/glib/tests/cond.c
index 0f0b3d249..ed338cce3 100644
--- a/glib/tests/cond.c
+++ b/glib/tests/cond.c
@@ -29,7 +29,7 @@
 
 static GCond cond;
 static GMutex mutex;
-static volatile gint next;
+static gint next;  /* locked by @mutex */
 
 static void
 push_value (gint value)
diff --git a/glib/tests/gwakeuptest.c b/glib/tests/gwakeuptest.c
index 461a7d3de..b37fb43fc 100644
--- a/glib/tests/gwakeuptest.c
+++ b/glib/tests/gwakeuptest.c
@@ -92,7 +92,7 @@ struct context
 static struct context contexts[NUM_THREADS];
 static GThread *threads[NUM_THREADS];
 static GWakeup *last_token_wakeup;
-static volatile gint tokens_alive;
+static gint tokens_alive;  /* (atomic) */
 
 static void
 context_init (struct context *ctx)
diff --git a/glib/tests/hash.c b/glib/tests/hash.c
index 4623d18d1..f4ff55ce1 100644
--- a/glib/tests/hash.c
+++ b/glib/tests/hash.c
@@ -1362,7 +1362,7 @@ struct _GHashTable
 
   GHashFunc        hash_func;
   GEqualFunc       key_equal_func;
-  volatile gint    ref_count;
+  gint             ref_count;  /* (atomic) */
 
 #ifndef G_DISABLE_ASSERT
   int              version;
diff --git a/glib/tests/slice.c b/glib/tests/slice.c
index f37826f3a..a566280db 100644
--- a/glib/tests/slice.c
+++ b/glib/tests/slice.c
@@ -107,7 +107,7 @@ thread_allocate (gpointer data)
   gint b;
   gint size;
   gpointer p;
-  volatile gpointer *loc;
+  gpointer *loc;  /* (atomic) */
 
   for (i = 0; i < 10000; i++)
     {
-- 
2.30.1