Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add atomic fallback for CXX without std::atomic #319

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PetervdPerk-NXP
Copy link
Contributor

When compiling zenoh-pico on an embedded rtos without std::atomic you'll get <atomic> include errors. This patch provides a way to implement some of the c11 atomics used in pointer.h in CXX.

It's just an attempt maybe someone has an idea for a cleaner approach, also it's the question other parts of zenoh-pico are going to utilize c11 atomic.

CMakeLists.txt Outdated
@@ -62,6 +62,11 @@ endif()
set(CMAKE_C_STANDARD_REQUIRED TRUE)
add_definition(ZENOH_C_STANDARD=${CMAKE_C_STANDARD})

# Useful for CXX platforms that don't provide std::atomic
if(CXX_ATOMIC_FALLBACK)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you validate this using check_cxx_source_compiles? In that way, the fallback would happen automatically without the need for the user to specify this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use check_cxx_source_compiles it works on my machine, but it seems that the CI doesn't expose it

@@ -19,7 +19,7 @@

#if ZENOH_C_STANDARD != 99

#ifndef __cplusplus
#if !defined(__cplusplus) || ZENOH_CXX_ATOMIC_FALLBACK

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 2009 with no text in the supplied rule-texts-file Warning

misra violation 2009 with no text in the supplied rule-texts-file
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.

None yet

2 participants