gcc提供的原子内置代码是否真的被翻译成示例代码,或者只是为了说明目的?

gcc提供的原子内置代码是否真的被翻译成示例代码,或者只是为了说明目的?,gcc,atomic,Gcc,Atomic,所以我在读的时候,发现了这个: 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 retu

所以我在读的时候,发现了这个:

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

这是文字代码吗?或者只是为了解释gcc使用类似c的语法在原子上做了什么?如果这是直接翻译,有人能解释它是如何原子的吗?

没有。代码只是用来说明函数是如何运行的

原子函数不是用c编写的,而是用每个体系结构的汇编语言编写的。由于某些体系结构没有实现原子操作所需的指令,因此并非所有操作在每个体系结构上都有效