Browse Source

posix: clock: create z_clock_gettime().. convenience functions.

To facilitate moving gettimeofday() and clock_nanosleep() to separate
compilation units, make z_clock_nanosleep(), z_clock_gettime(),
and z_clock_settime() convenience functions.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
pull/89922/head
Chris Friedt 3 months ago committed by Anas Nashif
parent
commit
73ee23e3ad
  1. 18
      lib/posix/options/clock.c

18
lib/posix/options/clock.c

@ -61,7 +61,7 @@ int z_vrfy___posix_clock_get_base(clockid_t clock_id, struct timespec *ts) @@ -61,7 +61,7 @@ int z_vrfy___posix_clock_get_base(clockid_t clock_id, struct timespec *ts)
#include <zephyr/syscalls/__posix_clock_get_base_mrsh.c>
#endif
int clock_gettime(clockid_t clock_id, struct timespec *ts)
int z_clock_gettime(clockid_t clock_id, struct timespec *ts)
{
struct timespec base;
@ -97,6 +97,10 @@ int clock_gettime(clockid_t clock_id, struct timespec *ts) @@ -97,6 +97,10 @@ int clock_gettime(clockid_t clock_id, struct timespec *ts)
return 0;
}
int clock_gettime(clockid_t clock_id, struct timespec *ts)
{
return z_clock_gettime(clock_id, ts);
}
int clock_getres(clockid_t clock_id, struct timespec *res)
{
@ -128,7 +132,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res) @@ -128,7 +132,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
* Note that only the `CLOCK_REALTIME` clock can be set using this
* call.
*/
int clock_settime(clockid_t clock_id, const struct timespec *tp)
int z_clock_settime(clockid_t clock_id, const struct timespec *tp)
{
struct timespec base;
k_spinlock_key_t key;
@ -156,6 +160,10 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp) @@ -156,6 +160,10 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp)
return 0;
}
int clock_settime(clockid_t clock_id, const struct timespec *tp)
{
return z_clock_settime(clock_id, tp);
}
/*
* Note: usleep() was removed in Issue 7.
@ -192,7 +200,7 @@ int usleep(useconds_t useconds) @@ -192,7 +200,7 @@ int usleep(useconds_t useconds)
*
* See IEEE 1003.1
*/
static int __z_clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
int z_clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
struct timespec *rmtp)
{
uint64_t ns;
@ -255,13 +263,13 @@ do_rmtp_update: @@ -255,13 +263,13 @@ do_rmtp_update:
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
return __z_clock_nanosleep(CLOCK_MONOTONIC, 0, rqtp, rmtp);
return z_clock_nanosleep(CLOCK_MONOTONIC, 0, rqtp, rmtp);
}
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
struct timespec *rmtp)
{
return __z_clock_nanosleep(clock_id, flags, rqtp, rmtp);
return z_clock_nanosleep(clock_id, flags, rqtp, rmtp);
}
/**

Loading…
Cancel
Save