Closed zephyrbot closed 7 years ago
by Claudiu Zissulescu:
Hi,
Atomic builtins are available only for ARCHS processors as they have LLOCK and SCOND instructions. Others ARC cpus need use inline assembly/builins to implement the desired ops.
Cheers, Claudiu
by Andrew Boie:
That's somewhat tangential to the point of this JIRA. If the HW doesn't have native instructions, I think there should still exist implementations of _sync* functions.
{quote} Not all operations are supported by all target processors. If a particular operation cannot be implemented on the target processor, a warning will be generated and a call an external function will be generated. The external function will carry the same name as the builtin, with an additional suffix `_n' where n is the size of the data type. {quote}
For example Nios II doesn't have hardware division, so GCC pulls in division functions instead.
by Claudiu Zissulescu:
Division is something else as it is essential for the compiler. Usually all the essential compiler operations which are not supported by hw are implemented via emulation using libgcc.
However, atomic ops are used in a multi-processor environment, hence, if you do not have support for this, it seems to me useless to have something there. Anyhow, if ones needs atomic support, gcc comes with libatomic, but one needs to target it for ARC.
Cheers, Claudiu
by Andrew Boie:
I'm not following your argument. The GCC manual (quoted above) states that function calls will be emitted if the necessary ASM operations aren't present. Are you saying implementation of __sync_fetchand* is an exercise for the end user?
by Claudiu Zissulescu:
It may be, as I do not know if your ARC variant has or not support for MP. libAtomic is coming with a software implementation but it may ask for some OS support. Otherwise, you can just make a simple lib having those builtins names and with a simple implementation as u do not need to sync the variables on a single processor. As you indicated GCC will create that call, but someone needs to provide a library.
On the other hand, maybe libatomic is already there and you just need to add -latomic when linking. Just try it.
by Mark Linkmeyer:
Per review with Anas and Juro: "Support for multiprocessors will come at some point in the future."
by Andrew Boie:
This is orthogonal to multiprocessing and is an issue on uniprocessor systems (example: interrupt handling)
by Mark Linkmeyer:
Per review with Juro, someone needs to create the implementation behind the stubbed-out functions for ARC and NIOS II.
Reported by Andrew Boie:
In testing this patch I found that I get linker errors on ARC and Nios II:
https://gerrit.zephyrproject.org/r/3291
It seems that the current compiler versions do not support these operations.
https://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/Atomic-Builtins.html
Errors typically resemble:
(Imported from Jira SDK-46)