summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorcopilot-swe-agent[bot] <[email protected]>2025-12-28 23:36:08 +0000
committercopilot-swe-agent[bot] <[email protected]>2025-12-28 23:36:08 +0000
commit533806c34416a08c566608d3e776eeca4abff10d (patch)
treebe59df645e938d655596462e70d45f2e5b6bc005 /components
parentc7d1918e3784cc69f0e945f8189bad224cafff1e (diff)
[clock_time] Fix rt_timespec_to_tick availability for POSIX semaphorescopilot/refactor-hwtimer-ktime-cputime
- Moved rt_timespec_to_tick outside of RT_USING_CLOCK_TIME guard - Function now available with just RT_USING_POSIX_CLOCK defined - Fixes undefined reference error when building with POSIX semaphores - Maintains backward compatibility with configurations that don't use clock_time yet Co-authored-by: BernardXiong <[email protected]>
Diffstat (limited to 'components')
-rw-r--r--components/libc/compilers/common/ctime.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/components/libc/compilers/common/ctime.c b/components/libc/compilers/common/ctime.c
index 437a5af602..def4eb1cd4 100644
--- a/components/libc/compilers/common/ctime.c
+++ b/components/libc/compilers/common/ctime.c
@@ -750,6 +750,17 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
}
RTM_EXPORT(clock_settime);
+#endif /* RT_USING_POSIX_CLOCK && RT_USING_CLOCK_TIME */
+
+#ifdef RT_USING_POSIX_CLOCK
+/**
+ * @brief Convert absolute timespec to relative tick
+ * @param time Absolute time
+ * @return Relative tick value
+ *
+ * @note This function is available when RT_USING_POSIX_CLOCK is defined,
+ * regardless of RT_USING_CLOCK_TIME, to support POSIX semaphores and other APIs.
+ */
int rt_timespec_to_tick(const struct timespec *time)
{
int tick;
@@ -784,7 +795,7 @@ int rt_timespec_to_tick(const struct timespec *time)
}
RTM_EXPORT(rt_timespec_to_tick);
-#endif /* RT_USING_POSIX_CLOCK && RT_USING_CLOCK_TIME */
+#endif /* RT_USING_POSIX_CLOCK */
#if defined(RT_USING_POSIX_TIMER) && defined(RT_USING_CLOCK_TIME)