• Boqun Feng's avatar
    powerpc: atomic: Implement atomic{, 64}_*_return_* variants · b8294f4e
    Boqun Feng authored
    BugLink: http://bugs.launchpad.net/bugs/1556096
    
    On powerpc, acquire and release semantics can be achieved with
    lightweight barriers("lwsync" and "ctrl+isync"), which can be used to
    implement __atomic_op_{acquire,release}.
    
    For release semantics, since we only need to ensure all memory accesses
    that issue before must take effects before the -store- part of the
    atomics, "lwsync" is what we only need. On the platform without
    "lwsync", "sync" should be used. Therefore in __atomic_op_release() we
    use PPC_RELEASE_BARRIER.
    
    For acquire semantics, "lwsync" is what we only need for the similar
    reason.  However on the platform without "lwsync", we can use "isync"
    rather than "sync" as an acquire barrier. Therefore in
    __atomic_op_acquire() we use PPC_ACQUIRE_BARRIER, which is barrier() on
    UP, "lwsync" if available and "isync" otherwise.
    
    Implement atomic{,64}_{add,sub,inc,dec}_return_relaxed, and build other
    variants with these helpers.
    Signed-off-by: default avatarBoqun Feng <boqun.feng@gmail.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    (cherry picked from commit dc53617c)
    Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
    b8294f4e
atomic.h 11.1 KB