Skip to content

posix: clock: implement clock_getres() #70525

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
Mar 22, 2024

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Mar 20, 2024

Add an implementation of clock_getres(). Clock resolution is currently limited to the inverse of CLOCK_TICKS_PER_SECOND as there is no direct relationship between hardware clocks and the POSIX variety in Zephyr.

The clock_getres() function is required by the POSIX_TIMERS Option Group as detailed in Section E.1 of IEEE-1003.1-2017.

The POSIX_TIMERS Option Group is required for PSE51, PSE52, PSE53, and PSE54 conformance, and is otherwise mandatory for any POSIX conforming system as per Section A.2.1.3 of IEEE-1003-1.2017.

With this, we have complete support for the POSIX_TIMERS Option Group.

Fixes #59955

@cfriedt cfriedt requested review from jukkar and ycsin March 20, 2024 22:34
@@ -97,6 +97,28 @@ int clock_gettime(clockid_t clock_id, struct timespec *ts)
return 0;
}

int clock_getres(clock_t clock_id, struct timespec *res)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
int clock_getres(clock_t clock_id, struct timespec *res)
int clock_getres(clockid_t clock_id, struct timespec *res)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed!

@cfriedt cfriedt requested a review from ycsin March 21, 2024 04:10
cfriedt added 3 commits March 21, 2024 00:18
clock_getres() is required by the POSIX_TIMERS Option Group
as detailed in Section E.1 of IEEE-1003.1-2017.

The POSIX_TIMERS Option Group is required for PSE51, PSE52,
PSE53, and PSE54 conformance, and is otherwise mandatory for
any POSIX conforming system as per Section A.2.1.3 of
IEEE-1003-1.2017.

With this, we have complete support for the POSIX_TIMERS
Option Group.

Signed-off-by: Christopher Friedt <[email protected]>
Add a test for clock_getres().

Signed-off-by: Christopher Friedt <[email protected]>
Mark clock_getres() as supported in the POSIX_TIMERS Option
Group.

Signed-off-by: Christopher Friedt <[email protected]>
@cfriedt cfriedt marked this pull request as ready for review March 21, 2024 04:22
@zephyrbot zephyrbot added the area: POSIX POSIX API Library label Mar 21, 2024
@cfriedt cfriedt requested a review from a user March 21, 2024 04:24
@cfriedt
Copy link
Member Author

cfriedt commented Mar 22, 2024

It looks like the 2d review period is up now.

@cfriedt cfriedt merged commit 457e440 into zephyrproject-rtos:main Mar 22, 2024
@cfriedt cfriedt deleted the clock-getres branch March 22, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: POSIX POSIX API Library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

posix: implement clock_getres()
4 participants