-
Notifications
You must be signed in to change notification settings - Fork 3k
Remove float symbols from apps that use the NFCController class #12401
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
Conversation
9636fca
to
4ba9e9c
Compare
drivers/Ticker.h
Outdated
#else | ||
template <typename F> MBED_FORCEINLINE | ||
#endif | ||
void attach(F &&func, float t) |
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.
Why is the forwarding being dropped? It reduced code size (by avoiding a relatively-expensive Callback
->Callback
copy). Does it have any bearing on the float
elimination?
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.
No it does not. I was checking if float elimination needed that. I will put it back for code size reduction.
drivers/Ticker.h
Outdated
{ | ||
attach_us(std::forward<F>(func), t * 1000000.0f); | ||
attach_us(func, (int)(t * 1000000)); |
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.
This breaks the API for anything >2000s. Is it the limiting to 32-bit that is making the difference for your test?
And that test is a non-constant use, I gather? Someone passing a non-constant integer to this?
If trying to avoid float use, you should fix the calling code to not use floats, not break this API.
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.
Changing the calling code as follows without making any changes to Ticker.h
does not remove float symbols.
void NFCController::scheduler_process(bool hw_interrupt)
{
_timeout.detach(); // Cancel timeout - if it triggers, it's ok as we'll have an "early" iteration which will likely be a no-op
// Process stack events
uint32_t timeout_ms = nfc_scheduler_iteration(_scheduler, hw_interrupt ? EVENT_HW_INTERRUPT : EVENT_NONE);
_timeout.attach(
callback(this, &NFCController::on_timeout),
timeout_ms/1000 // convert milliseconds to seconds <=====
);
}
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.
Well, no, because you're still using the attach(float)
.
That should be
_timeout.attach_us(cb(blah), timeout_ms * (us_timestamp_t) 1000);
(Cast needed to ensure it's a 64-bit multiply, not a 32-bit one).
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.
Done.
4ba9e9c
to
42bf813
Compare
Pull request has been modified.
Use the `Ticker` API that does not use floating point types and literal. Also pass timeout in seconds instead of incorrectly passing milliseconds.
42bf813
to
ec2c341
Compare
Ticker
module
@hugueskamba, thank you for your changes. |
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.
Simple change at the end :-)
You might want to repeat the title in the Impact of change
section.
The description is a bit backwards - the main change is now the 1000 times scheduling speed-up, not the removal of float use, even if it's not the reason you approached it in the first place. As such, it should be reviewed by @donatieng or @pan- or someone in NFC area. I can only assume there was a lack of test coverage here - nothing actually needing to trigger any retries? |
CI started meanwhile |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Set this one for review stage |
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.
LGTM
Summary of changes
Use the
Ticker
API that does not use floating point types and literal.Also pass timeout in seconds instead of incorrectly passing milliseconds.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers
@kjbracey-arm @evedon