blob: 9468548e3ab375db4015b897aa9ab2f533c4d0b0 [file] [log] [blame]
Andrew Geissler95ac1b82021-03-31 14:34:31 -05001From 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 doesnt 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