Different signature for atomic_compare_exchange_n builtin function and libatomic implementation

Jonathan Wakely jwakely.gcc@gmail.com
Mon Feb 11 10:07:00 GMT 2019

On Sun, 10 Feb 2019 at 21:37, <semi1@posteo.de> wrote:
> Hello,
> i have a question regarding the function signature of some atomic
> functions/builtins.
> On https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
> compare_exchange has the signature: "bool __atomic_compare_exchange_n
> (type *ptr, type *expected, type desired, bool weak, int
> success_memorder, int failure_memorder)"

This is the exact function signature. The name ends with "_n" not "_4".

> On https://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary it has the signature
> "bool  __atomic_compare_exchange_N (IN *mem, IN *expected, IN desired,
> int success, int failure)"

That page is an old design document, describing the implementation
plan, not the final status. Use the manual, not the wiki page.

> When i try to use __atomic_compare_exchange_4 with 5 arguments i get
> following error: too few arguments to function
> ‘__atomic_compare_exchange_4’.
> How can can i call the library function?

Call one of the functions shown in the
page, using exactly the signature shown there.

Do not call __atomic_compare_exchange_4. That isn't in the docs.

More information about the Gcc-help mailing list