gatomic: Cast the oldval pointer type to the atomic value type

If glib_typeof is defined we can try to cast the old value to the atomic
value type to check if it's compatible with the pointer one.

Closes: #2798
This commit is contained in:
Marco Trevisan (Treviño) 2022-10-29 04:18:15 +02:00
parent 6cb10c86c8
commit e2560d1681

View File

@ -241,7 +241,8 @@ G_END_DECLS
* https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1715#note_1024120. */
#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \
(G_GNUC_EXTENSION ({ \
G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \
G_STATIC_ASSERT (sizeof (static_cast<glib_typeof (*(atomic))>((oldval))) \
== sizeof (gpointer)); \
glib_typeof (*(atomic)) gapcae_oldval = (oldval); \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
(void) (0 ? (gpointer) *(atomic) : NULL); \