Skip to content

Commit 73ee23e

Browse files
cfriedtnashif
authored andcommitted
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>
1 parent 5c46fcb commit 73ee23e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/posix/options/clock.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int z_vrfy___posix_clock_get_base(clockid_t clock_id, struct timespec *ts)
6161
#include <zephyr/syscalls/__posix_clock_get_base_mrsh.c>
6262
#endif
6363

64-
int clock_gettime(clockid_t clock_id, struct timespec *ts)
64+
int z_clock_gettime(clockid_t clock_id, struct timespec *ts)
6565
{
6666
struct timespec base;
6767

@@ -97,6 +97,10 @@ int clock_gettime(clockid_t clock_id, struct timespec *ts)
9797

9898
return 0;
9999
}
100+
int clock_gettime(clockid_t clock_id, struct timespec *ts)
101+
{
102+
return z_clock_gettime(clock_id, ts);
103+
}
100104

101105
int clock_getres(clockid_t clock_id, struct timespec *res)
102106
{
@@ -128,7 +132,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
128132
* Note that only the `CLOCK_REALTIME` clock can be set using this
129133
* call.
130134
*/
131-
int clock_settime(clockid_t clock_id, const struct timespec *tp)
135+
int z_clock_settime(clockid_t clock_id, const struct timespec *tp)
132136
{
133137
struct timespec base;
134138
k_spinlock_key_t key;
@@ -156,6 +160,10 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp)
156160

157161
return 0;
158162
}
163+
int clock_settime(clockid_t clock_id, const struct timespec *tp)
164+
{
165+
return z_clock_settime(clock_id, tp);
166+
}
159167

160168
/*
161169
* Note: usleep() was removed in Issue 7.
@@ -192,7 +200,7 @@ int usleep(useconds_t useconds)
192200
*
193201
* See IEEE 1003.1
194202
*/
195-
static int __z_clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
203+
int z_clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
196204
struct timespec *rmtp)
197205
{
198206
uint64_t ns;
@@ -255,13 +263,13 @@ static int __z_clock_nanosleep(clockid_t clock_id, int flags, const struct times
255263

256264
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
257265
{
258-
return __z_clock_nanosleep(CLOCK_MONOTONIC, 0, rqtp, rmtp);
266+
return z_clock_nanosleep(CLOCK_MONOTONIC, 0, rqtp, rmtp);
259267
}
260268

261269
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
262270
struct timespec *rmtp)
263271
{
264-
return __z_clock_nanosleep(clock_id, flags, rqtp, rmtp);
272+
return z_clock_nanosleep(clock_id, flags, rqtp, rmtp);
265273
}
266274

267275
/**

0 commit comments

Comments
 (0)