-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
sys/irq: Add C++ wrapper using RAII #17066
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR, this looks pretty good to me. I added some comments inline.
core/include/irq.hpp
Outdated
irq_restore(state); | ||
} | ||
|
||
irq_lock(irq_lock const& irq) = delete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to myself: Check if it is possible to get rid of the bogus "keyword 'delete' not followed by a single space" warning of the CI.
This PR also introduces the fff package. I'd like to also see a test application in C, just for it. |
@aabadie I've added a test |
Thanks! I think the addition of the fff package and the test application could into their own separate PR to simplify the review. |
Also make sure that you read our CONTRIBUTING guidelines and especially the section about commit conventions and about fixup commits. |
This needs a squashing, right? |
Yes. I fear that squashing done by anyone else except the author results in the PR being closes (likely a security feature to avoid sneaking in unrelated code while obfuscating the commit history / authorship). At least this was what happened the last two times a maintainer squashed a PR she/he didn't open. But then again, I could just open a new PR if that happens and keep the correct authorship in the commit meta data. |
it worked for #12353 😇 |
Hey guys I am sorry for the long delay in communication. I was a few months abroad without regular access to my computer. I will make the PR ready for merging asap in the next weeks. |
c6f920a
to
467d61a
Compare
467d61a
to
a9c5987
Compare
@jenswet: Thx :) I the squashing (and the disabling of ESP8266) was the only thing missing. Let's see if we can get this in now. bors merge |
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
bors retry |
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
bors cancel |
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
bors cancel |
bors merge |
bors r+ |
bors retry |
bors ping |
pong |
Already running a review |
1 similar comment
Already running a review |
Build succeeded: |
🎉 @jenswet: Thanks for your patience :) I'm confident that the next PR should get in much quicker :) |
Contribution description
This adds a C++ wrapper around the
irq.h
API. The wrapper uses RAII to accomplish a convenient and bug resistent use.A little background: I'm currently writing my master thesis on using C++ for embedded development, at the working group that @maribu is part of. For that I will try to add better C++ support to several parts of RIOT and then do some benchmarking and metrics to compare it with the C implementation. For example, I also plan to add a wrapper around i2c, a std::cout drop-in replacement and probably some more about networks or threads.
Testing procedure
I've added a unit test to verify that the IRQ wrapper calls the original
irq
functions as expected. As C++ and wrapper testing isn't done much so far in this project, I've added two additional headers to ease testing:Both of this is obviously not required for the initial reason of this PR. But I'd like to provide unit tests for the features that I suggest to introduce where possible. So I'd appreciate some feedback on that too. If you'd prefer a PR without or different tests please let me know.
You can run the test
irq_cpp
locally or on the CI to test the implementation.Please feel free to give feedback or suggest improvements!