rx-gcc atomic builtin support
rx-gcc atomic builtin support
What’s the proper way to use gcc builtins with the rx-gcc-14?
I’m attempting to use `__atomic_or_fetch` and `__atomic_and_fetch` for cross-platform portability, but this fails with:
“undefined reference to `__atomic_fetch_or_1`” and “undefined reference to `__atomic_fetch_and_1′”
Adding `-latomic` to the linker doesn’t help at all.
Unfortunately, I’m stuck with c99.
×

English
Hello,
Thank you for reaching out to us!
“libatomic” is not included with the GCC for Renesas RX toolchains and we provide no support for it at the moment.
Please let us know if we can be of assistance with any other issues.
Best regards,
The Open Source Tools Team
It was my understanding that the “builtin” gcc functions were not tied to an external library, obviously this is not the case.
Is there a known feature test macro for this?
Hello,
As stated explicitly in the C17 standard (7.17.1 6.)
It is unspecified whether any generic function declared in is a macro or an identifier declared with external linkage.
The compiler may expand the function inline or it may rely on external implementation. This behavior may also depend not only on the function but on the argument types the function was called with.
For example:
unsigned int flags = 0b00000001;
unsigned int old_flags = atomic_fetch_or(&flags, 0b00000100);
will be expanded inline and it will link successfully.
The following, however, will fall back to a library call and result in the linker error you encountered:
unsigned char flags = 0b00000001;
unsigned char old_flags = atomic_fetch_or(&flags, 0b00000100);
There are no macros to check whether an inline expansion or a library call will be used. The current implementation of the compiler for RX expands inline only the 4 byte variant of the function.
Please let us know if we can be of assistance with any other issues.
Best regards,
The Open Source Tools Team
Thanks. That clears up the situation nicely.