Skip to content

Fix rtapi atomics#3856

Merged
andypugh merged 2 commits intoLinuxCNC:masterfrom
BsAtHome:fix_rtapi-atomics
Mar 11, 2026
Merged

Fix rtapi atomics#3856
andypugh merged 2 commits intoLinuxCNC:masterfrom
BsAtHome:fix_rtapi-atomics

Conversation

@BsAtHome
Copy link
Contributor

The atomics for C and C++ were not entirely functional when using clang. Partly functionality was provided by the rtapi_atomc.h header by (re-)defining some parts, but these should come from the compiler's headers (C:<stdatomic.h> and C++:<atomic>). As a consequence, only the copied explicit load/store operations were possible and non of the other atomic operations would be available or function with clang.

The main culprit was the misspelling of the __STDC_VERSION__ macro in the rtapi header, missing the trailing underscores and a wrong comparison.
Atomics are provided in C11 and newer. This means that the minimum C-compiler support is C11. But this should not be any problem because we already require a very much newer C++20 on the other side.

Some further adjustments were required once the macro got fixed because using atomic operations with clang requires the variables to be marked as actually atomic variables. That meant moving some private internal structures out of public headers into private space, where these variables could be safely marked as being atomic. One boost header needed to be included before rtapi_atomic.h or the boost header would cause problems.

@andypugh andypugh merged commit f3b961b into LinuxCNC:master Mar 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants