mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 03:02:10 +01:00
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:
parent
6cb10c86c8
commit
e2560d1681
@ -241,7 +241,8 @@ G_END_DECLS
|
|||||||
* https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1715#note_1024120. */
|
* https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1715#note_1024120. */
|
||||||
#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \
|
#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \
|
||||||
(G_GNUC_EXTENSION ({ \
|
(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); \
|
glib_typeof (*(atomic)) gapcae_oldval = (oldval); \
|
||||||
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
||||||
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user