summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2020-11-16 14:47:47 +0000
committerPhilip Withnall <pwithnall@endlessos.org>2020-11-20 14:40:19 +0000
commit2d03f99ae4de394cac0690717d96c2d884ccdae2 (patch)
tree9ab9bba232f271197b3512433b37a08ad61c36d3
parent0604f5858259c32744e6fc912ed4feb308651a3a (diff)
downloadglib-2d03f99ae4de394cac0690717d96c2d884ccdae2.tar.gz
tests: Add comment to volatile atomic tests
`volatile` should not be used to indicate atomic variables, and we shouldn’t encourage its use. Keep the tests, since they check that we don’t emit warnings when built against incorrect old code which uses `volatile`. But add a comment to stop copy/paste use of `volatile` in the future. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #600
-rw-r--r--glib/tests/atomic.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c
index 7d2459f3a..14e6e454e 100644
--- a/glib/tests/atomic.c
+++ b/glib/tests/atomic.c
@@ -94,6 +94,9 @@ test_types (void)
res = g_atomic_pointer_compare_and_exchange (&vp_str, NULL, str);
g_assert_true (res);
+ /* Note that atomic variables should almost certainly not be marked as
+ * `volatile` — see http://isvolatileusefulwiththreads.in/c/. This test exists
+ * to make sure that we don’t warn when built against older third party code. */
g_atomic_pointer_set (&vp_str_vol, NULL);
res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, str);
g_assert_true (res);
@@ -210,6 +213,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
res = g_atomic_pointer_compare_and_exchange (&vp_str, NULL, (char *) str);
g_assert_true (res);
+ /* Note that atomic variables should almost certainly not be marked as
+ * `volatile` — see http://isvolatileusefulwiththreads.in/c/. This test exists
+ * to make sure that we don’t warn when built against older third party code. */
g_atomic_pointer_set (&vp_str_vol, NULL);
res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, (char *) str);
g_assert_true (res);