Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 1 | From 8a112c3c6e5fe6838ee29eec7caa62ba32d9bc40 Mon Sep 17 00:00:00 2001 |
| 2 | From: Philip Withnall <pwithnall@endlessos.org> |
| 3 | Date: Wed, 11 Nov 2020 19:22:49 +0000 |
| 4 | Subject: [PATCH 21/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 | gobject/tests/qdata.c | 2 +- |
| 18 | gobject/tests/threadtests.c | 4 ++-- |
| 19 | 2 files changed, 3 insertions(+), 3 deletions(-) |
| 20 | |
| 21 | diff --git a/gobject/tests/qdata.c b/gobject/tests/qdata.c |
| 22 | index 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) |
| 34 | diff --git a/gobject/tests/threadtests.c b/gobject/tests/threadtests.c |
| 35 | index 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 | -- |
| 50 | 2.30.1 |
| 51 | |