-
Peter Wu authored
__atomic_load_8 and friends do not exist under clang. Use the generic __atomic_load variant instead that are documented here: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html These have the additional benefit that the exact size of gint (4 bytes) or gpointer (4 or 8 bytes) no longer have to be checked. I initially tried `__typeof__(*(atomic)) val;`, but that caused warnings in Clang (-Wincompatible-pointer-types-discards-qualifiers) when "atomic" points to a volatile variable. Aside from that, it is apparently not supported everywhere, see the g_has_typeof macro. Another reason not to use it are new warnings under Clang, including: glib/deprecated/gthread-deprecated.c:683:11: warning: incompatible pointer types initializing 'typeof (*(&mutex->mutex.mutex))' (aka 'union _GMutex *') with an expression of type 'GRecMutex *' (aka 'struct _GRecMutex *') [-Wincompatible-pointer-types] g_atomic_pointer_set (&mutex->mutex.mutex, result); Hence, cast the atomic variable to gint/gpointer pointers, the size was already statically asserted so the cast should be safe. The macros use a (hopefully) rare "gaps_temp" name instead of something like "val" to avoid an issue with GCC builds: glib/tests/once.c:123:test_once4: assertion failed (val == "foo"): (NULL == "foo") Closes #1843
a3d90c07