-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys: some simple xtimer->ztimer conversions #17693
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.
As discussed in the sprint day meeting, to do this the concerned modules should IMO explicitly include ztimer_xtimer_compat
, otherwise its too easy to end up with cases with things like:
In file included from uhcpc.c:16:
../../../include/ztimer/xtimer_compat.h:58:18: error: conflicting types for ‘xtimer_t’
58 | typedef ztimer_t xtimer_t;
| ^~~~~~~~
In file included from ../../../include/net/gnrc/netif/pktq/type.h:27,
from ../../../include/net/gnrc/netif.h:63,
from ../../../include/net/gnrc.h:294,
from ../../gnrc/sock/include/sock_types.h:30,
from ../../../include/net/sock/udp.h:685,
from uhcpc.c:13:
Otherwise, it's just not a maintainable approach system-wise, it will work here and there but not be a pattern to reproduce.
in essence this come down to gnrc exposing the timer implementation used internal throughout the stack right into the user from
its is include creep similar to #17574 udcpc should not need to care what timer the pktq uses (it is usesd at netif level and only there) udcpc is miles away from that right now i am trying to find the point where we can introduce a cut in the include chain in gnrc |
d62b63c
to
73d91a7
Compare
41ceb56
to
20de2dc
Compare
802af17
to
aee2c05
Compare
fcd92aa
to
8347342
Compare
I'm still not convinced of this approach, not making dependency explicit seems like something that is just prone to break, The header cleanup I'm all in favor, and is not tied to the other changes right? 0891530 can you explain these changes? |
Was there an issue with
Yes, Separate PR for that first. #17714
I tried to make these all Test (just with one Board - to find most of the missing includes before uploading to Murdock). |
It worked because no
Yes but not exposing it was the issue, because then if there was a user of |
8347342
to
88b4846
Compare
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.
#17726 build successfully |
I'm still not in favor of this:
|
you are right there should only be one ifeq for all these prefer ztimer_usec but fallback to xtimer modules we can remove the fallback option for these modules if we always have a ztimer
These modules use ztimer and only fallback to xtimer if no one else uses it (kindoff due to the fact the decision is done when the module use is evaluated it might got it worng -> going to change that since no one likes a xtimer that has no job)
these module are able to use ztimer through its xtimer_compat interface -> they do not need the roundtrip through xtimer.h that is probaly ending at ztimer64_usec, they are perfectly fine working with ztimer_usec even if something else requieres ztimer64 or ztimer64_xtimer_compat
Aren't we doing this right now? seems like we are on a good track to no xtimer in 2-3 months |
88b4846
to
2047fb3
Compare
71d7062
to
5448eb7
Compare
This one needs a rebase! |
5448eb7
to
3cf5f64
Compare
ifneq (,$(filter xztimer_fallback,$(USEMODULE))) | ||
USEMODULE := $(filter-out xztimer_fallback,$(USEMODULE)) | ||
ifeq (,$(filter ztimer_usec,$(USEMODULE))) | ||
USEMODULE += xtimer | ||
endif | ||
endif |
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 kind of pattern is not used and is not a good idea to use in the build system, it is very very prone to dependency order issues.
Are we sure this is still worth it with xtimer_ztimer_compat
being used by default now?
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 is a step to remove the xtimer support from these modules they should be easy conversion to ztimer. We may just remove the xtimer support from these modules entirely and skip this step.
I do not like writing these:
if there is ztimer
do this
elseif there is xtimer
do that
Even reading this kind of code not nice since it distracts from what is the main purpose of that module.
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.
Then instead how about adapting the coccinelle
scripts to have two versions a ztimer_xtimer_compat
version and a ztimer64_xtimer_compat
version, and simply spatch those files and directly make the conversion?
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.
#17892 has that done (without the coccinelle part)
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 kind of pattern is not used and is not a good idea to use in the build system, it is very very prone to dependency order issues.
somehow i think the xztimer_fallback
solves a dependency order issue for modules that support ztimer
as well as xtimer
through delaying the decision until it is necessary
If the first module in Makefile.dep supports x and z timer the dependancy will be decided at that point and every later module will see the decision done there but in reality the module did not care. - may be this needs another PR
Alt. Pr.: #17892 made it |
Contribution description
do some simple xtimer->ztimer conversions using 'ztimer/xtimer_compat.h'
These modules only use 32Bit of xtimer and and therefor are able to use ztimer (32) through xtimer_compat.h
Testing procedure
Issues/PRs references