Skip to content

kernel: extensions and clarifications to time-conversion changes #20457

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

Merged
merged 3 commits into from
Nov 8, 2019

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Nov 8, 2019

Several concerns raised in review of #19591 were not addressed. This provides the changes promised in #19591 (comment) to mitigate those concerns.

I don't insist on the move of the internal header to a less visible location, but it certainly didn't get the consideration I expected when I asked for it to be done in #19591 (review) or in #17155 (comment).

I can do nothing at this point about the essential-type changes made in-tree by the previous merge.

This isn't something the user will ever include directory, so take
steps to hide it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Some use cases require using high-resolution tick or cycle clocks to
measure sub-millisecond durations.  Generate the corresponding 32-bit
conversions to avoid the cost of 64-bit math in the common case where
the duration fits in 32 bits in both original and converted scale.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

This looks very sensible to me. I tried to check all the new conversion functions against the doc and they do look all correct. I did not check the parameters to z_tmcvt().

Copy link
Collaborator

@nordic-krch nordic-krch left a comment

Choose a reason for hiding this comment

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

lgtm

@carlescufi
Copy link
Member

@andyross could you please take a quick look before feature freeze?

@pabigot
Copy link
Collaborator Author

pabigot commented Nov 8, 2019

also please @nashif as the guardian of where include files go. Thank you.

@zephyrbot zephyrbot added area: API Changes to public APIs area: Tests Issues related to a particular existing or missing test area: Kernel labels Nov 8, 2019
@zephyrbot
Copy link
Collaborator

zephyrbot commented Nov 8, 2019

All checks are passing now.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

…ed API

The addition of API to correctly handle conversion between durations
in different clocks inadvertently changed the type of the value
produced by the API.  Specific changes were:

s32_t z_ms_to_ticks(s32_t t) =>
  u32_t k_ms_to_ticks_ceil32(u32_t t) : signedness change
s32_t __ticks_to_us(s32_t t) =>
  u64_t k_ticks_to_us_floor64(u64_t t) : signedness and rank change
s32_t z_us_to_ticks(s32_t t) =>
  u64_t k_us_to_ticks_ceil64(u64_t t) : signedness and rank change
int sys_clock_hw_cycles_per_tick() =>
  u32_t k_ticks_to_cyc_floor32(1) : signedness change

The effect of this is to change the essential type of operands in
existing expressions, potentially resulting in behavior changes when
calculations were promoted to unsigned types, or code size by
requiring 64-bot arithmetic.

Add casts as necessary to preserve the original return type, and to
explicitly recognize impact of passing macro parameters into a context
where a specific type will be used.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Copy link
Collaborator

@andyross andyross left a comment

Choose a reason for hiding this comment

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

Looks harmless, sure.

@nashif nashif merged commit ae5e5b7 into zephyrproject-rtos:master Nov 8, 2019
@pabigot pabigot deleted the nordic/19591 branch November 12, 2019 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Kernel area: Tests Issues related to a particular existing or missing test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants