Are the atomic builtins provided by gcc actually translated into the example code, or is that just f

Posted by Jared P on Stack Overflow See other posts from Stack Overflow or by Jared P
Published on 2010-03-12T21:22:38Z Indexed on 2010/03/12 21:27 UTC
Read the original article Hit count: 182

Filed under:
|

So I was reading http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html, and came across this:

type __sync_and_and_fetch (type *ptr, type value, ...)
type __sync_xor_and_fetch (type *ptr, type value, ...)
type __sync_nand_and_fetch (type *ptr, type value, ...)
These builtins perform the operation suggested by the name, and return the new value. That is,
      { *ptr op= value; return *ptr; }
      { *ptr = ~*ptr & value; return *ptr; }   // nand

Is this code literal? or is it just to explain what gcc is doing atomically using c-like syntax? And if this is the direct translation, can someone explain how it is atomic?

© Stack Overflow or respective owner

Related posts about gcc

Related posts about Atomic