blob: 4b7b6f463a7258e76a6dcbce21357cbde1a257cd [file] [log] [blame]
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 doesnt 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