Are atomic gcc built-in functions actually translated into sample code or is it just for illustrative purposes?

So, I read 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 just explain what gcc does atomically using c-like syntax? And if it's a direct translation, can someone explain how it is atomic?

+3
source share
1 answer

No. The code is only to illustrate the operation of these functions.

c, . , .

+1

Source: https://habr.com/ru/post/1736723/


All Articles