Skip to content

Commit 73635ea

Browse files
committed
libc: common: time: use k_clock api rather than posix
Remove POSIX clock_gettime() from the common libc time implementation, since POSIX should not be a dependency for ISO C. Signed-off-by: Chris Friedt <[email protected]>
1 parent cfc4a81 commit 73635ea

File tree

1 file changed

+4
-4
lines changed
  • lib/libc/common/source/time

1 file changed

+4
-4
lines changed

lib/libc/common/source/time/time.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/*
22
* Copyright (c) 2021 Golioth, Inc.
3+
* Copyright (c) 2025 Tenstorrent AI ULC
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
67

78
#include <time.h>
89

9-
/* clock_gettime() prototype */
10-
#include <zephyr/posix/time.h>
10+
#include <zephyr/kernel.h>
1111

1212
time_t time(time_t *tloc)
1313
{
1414
struct timespec ts;
1515
int ret;
1616

17-
ret = clock_gettime(CLOCK_REALTIME, &ts);
17+
ret = k_clock_gettime(K_CLOCK_REALTIME, &ts);
1818
if (ret < 0) {
19-
/* errno is already set by clock_gettime */
19+
errno = -ret;
2020
return (time_t) -1;
2121
}
2222

0 commit comments

Comments
 (0)