Skip to content
  • Allison Karlitskaya's avatar
    gatomic: introduce G_ATOMIC_LOCK_FREE · aba0f0c3
    Allison Karlitskaya authored
    We clean up the detection of if we should do 'real' atomic operations or
    mutex-emulated ones with the introduction of a new (public) macro:
    G_ATOMIC_LOCK_FREE.  If defined, our atomic operations are guaranteed to
    be done in hardware.
    
    We need to use __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to determine if our
    compiler supports GCC-style atomic operations from the gatomic.h header
    because we might be building a program against GLib using a different
    set of compiler options (or a different compiler) than was used to build
    GLib itself.
    
    Unfortunately, this macro is not available on clang, so it has currently
    regressed to using the mutex emulation.  A bug about that has been
    opened here:
    
      http://llvm.org/bugs/show_bug.cgi?id=11174
    aba0f0c3