Skip to content
  • Peter Wu's avatar
    gatomic: Fix false positive with Clang+TSAN · a3d90c07
    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, res...
    a3d90c07