fetch_and_add() available on PPC Linux?

David Edelsohn dje at watson.ibm.com
Thu Dec 6 15:17:29 EST 2001


	Have you looked at the atomicity macros for PowerPC in glibc?  You
want to use the load-linked store-conditional instructions.  Something
along the lines of:

0:
    lwarx   %1,0,%4         # oval = (*ptr) [linked]
    add%I3  %2,%1,%3        # tmp = oval + val
    stwcx.  %2,0,%4         # (*ptr) = tmp  [conditional]
    bne-    0b              # if (store failed) retry

David

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-dev mailing list