mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
Merge branch 'th/atomic-compare-and-exchange' into 'master'
atomic/tests: test g_atomic_pointer_compare_and_exchange() with const pointers See merge request GNOME/glib!1287
This commit is contained in:
commit
7aa91a0289
@ -24,6 +24,9 @@ test_types (void)
|
||||
guint u, u2;
|
||||
gint s, s2;
|
||||
gpointer vp, vp2;
|
||||
const char *vp_str;
|
||||
const char *volatile vp_str_vol;
|
||||
const char *str = "Hello";
|
||||
int *ip, *ip2;
|
||||
gsize gs, gs2;
|
||||
gboolean res;
|
||||
@ -87,6 +90,14 @@ test_types (void)
|
||||
g_assert_true (res);
|
||||
g_assert_true (vp == 0);
|
||||
|
||||
g_atomic_pointer_set (&vp_str, NULL);
|
||||
res = g_atomic_pointer_compare_and_exchange (&vp_str, NULL, str);
|
||||
g_assert_true (res);
|
||||
|
||||
g_atomic_pointer_set (&vp_str_vol, NULL);
|
||||
res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, str);
|
||||
g_assert_true (res);
|
||||
|
||||
g_atomic_pointer_set (&ip, 0);
|
||||
ip2 = g_atomic_pointer_get (&ip);
|
||||
g_assert_true (ip2 == 0);
|
||||
@ -195,6 +206,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_true (res);
|
||||
g_assert_true (vp == 0);
|
||||
|
||||
g_atomic_pointer_set (&vp_str, NULL);
|
||||
res = g_atomic_pointer_compare_and_exchange (&vp_str, NULL, (char *) str);
|
||||
g_assert_true (res);
|
||||
|
||||
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);
|
||||
|
||||
g_atomic_pointer_set (&ip, 0);
|
||||
ip2 = g_atomic_pointer_get (&ip);
|
||||
g_assert_true (ip2 == 0);
|
||||
|
Loading…
Reference in New Issue
Block a user