Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 1 | From 3dda662bebb81666d009635df1055ba5c1e17b52 Mon Sep 17 00:00:00 2001 |
| 2 | From: Philip Withnall <pwithnall@endlessos.org> |
| 3 | Date: Wed, 11 Nov 2020 18:16:17 +0000 |
| 4 | Subject: [PATCH 04/29] tests: Drop unnecessary volatile qualifiers from tests |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | These variables were already (correctly) accessed atomically. The |
| 10 | `volatile` qualifier doesn’t help with that. |
| 11 | |
| 12 | Signed-off-by: Philip Withnall <pwithnall@endlessos.org> |
| 13 | |
| 14 | Helps: #600 |
| 15 | Upstream-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 | |
| 24 | diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c |
| 25 | index 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) |
| 39 | diff --git a/glib/tests/cond.c b/glib/tests/cond.c |
| 40 | index 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) |
| 52 | diff --git a/glib/tests/gwakeuptest.c b/glib/tests/gwakeuptest.c |
| 53 | index 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) |
| 65 | diff --git a/glib/tests/hash.c b/glib/tests/hash.c |
| 66 | index 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; |
| 78 | diff --git a/glib/tests/slice.c b/glib/tests/slice.c |
| 79 | index 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 | -- |
| 92 | 2.30.1 |
| 93 | |