sys/irq: Add C++ wrapper using RAII#17066
Conversation
maribu
left a comment
There was a problem hiding this comment.
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.
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.hAPI. 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
irqfunctions 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_cpplocally or on the CI to test the implementation.Please feel free to give feedback or suggest improvements!