mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
gatomic: Check if glib_typeof() is defined before using it
This commit is contained in:
parent
5b2bee3f53
commit
a1847d0d03
@ -183,6 +183,7 @@ G_END_DECLS
|
||||
(guint) __atomic_fetch_xor ((atomic), (val), __ATOMIC_SEQ_CST); \
|
||||
}))
|
||||
|
||||
#if defined(glib_typeof)
|
||||
#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \
|
||||
@ -191,6 +192,16 @@ G_END_DECLS
|
||||
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
||||
__atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
|
||||
}))
|
||||
#else /* if !defined(glib_typeof) */
|
||||
#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \
|
||||
gpointer gapcae_oldval = (gpointer)(oldval); \
|
||||
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
||||
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
||||
__atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
|
||||
}))
|
||||
#endif /* defined(glib_typeof) */
|
||||
#define g_atomic_pointer_add(atomic, val) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
||||
@ -283,6 +294,7 @@ G_END_DECLS
|
||||
__asm__ __volatile__ ("" : : : "memory"); \
|
||||
gapg_result; \
|
||||
}))
|
||||
#if defined(glib_typeof)
|
||||
#define g_atomic_pointer_set(atomic, newval) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
||||
@ -291,6 +303,16 @@ G_END_DECLS
|
||||
__asm__ __volatile__ ("" : : : "memory"); \
|
||||
*(atomic) = (glib_typeof (*(atomic))) (gsize) (newval); \
|
||||
}))
|
||||
#else /* if !defined(glib_typeof) */
|
||||
#define g_atomic_pointer_set(atomic, newval) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
||||
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
||||
__sync_synchronize (); \
|
||||
__asm__ __volatile__ ("" : : : "memory"); \
|
||||
*(atomic) = (gpointer) (gsize) (newval); \
|
||||
}))
|
||||
#endif /* defined(glib_typeof) */
|
||||
|
||||
#define g_atomic_int_inc(atomic) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
@ -408,6 +430,6 @@ G_END_DECLS
|
||||
#define g_atomic_pointer_xor(atomic, val) \
|
||||
(g_atomic_pointer_xor ((atomic), (gsize) (val)))
|
||||
|
||||
#endif /* defined(__GNUC__) && defined(G_ATOMIC_OP_USE_GCC_BUILTINS) */
|
||||
#endif /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */
|
||||
|
||||
#endif /* __G_ATOMIC_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user