Skip to content

Commit 533806c

Browse files
CopilotBernardXiong
andcommitted
[clock_time] Fix rt_timespec_to_tick availability for POSIX semaphores
- 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 <1241087+BernardXiong@users.noreply.github.com>
1 parent c7d1918 commit 533806c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

  • components/libc/compilers/common

components/libc/compilers/common/ctime.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,17 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
750750
}
751751
RTM_EXPORT(clock_settime);
752752

753+
#endif /* RT_USING_POSIX_CLOCK && RT_USING_CLOCK_TIME */
754+
755+
#ifdef RT_USING_POSIX_CLOCK
756+
/**
757+
* @brief Convert absolute timespec to relative tick
758+
* @param time Absolute time
759+
* @return Relative tick value
760+
*
761+
* @note This function is available when RT_USING_POSIX_CLOCK is defined,
762+
* regardless of RT_USING_CLOCK_TIME, to support POSIX semaphores and other APIs.
763+
*/
753764
int rt_timespec_to_tick(const struct timespec *time)
754765
{
755766
int tick;
@@ -784,7 +795,7 @@ int rt_timespec_to_tick(const struct timespec *time)
784795
}
785796
RTM_EXPORT(rt_timespec_to_tick);
786797

787-
#endif /* RT_USING_POSIX_CLOCK && RT_USING_CLOCK_TIME */
798+
#endif /* RT_USING_POSIX_CLOCK */
788799

789800
#if defined(RT_USING_POSIX_TIMER) && defined(RT_USING_CLOCK_TIME)
790801

0 commit comments

Comments
 (0)