From 92f8f9b8f8cffdfbbb56e4c294ab31fcd445df13 Mon Sep 17 00:00:00 2001 From: ligd Date: Wed, 25 Sep 2024 11:45:01 +0800 Subject: [PATCH] clock: correct compile failed LD: nuttx.elf ld: /home/ligd/platform/mainline/nuttx/staging/libsched.a(mq_sndinternal.o): in function `wd_start_realtime': /home/ligd/platform/mainline/nuttx/include/nuttx/wdog.h:274: undefined reference to `clock_realtime2absticks' /home/ligd/platform/mainline/nuttx/include/nuttx/wdog.h:274:(.text+0xad): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `clock_realtime2absticks' ld: /home/ligd/platform/mainline/nuttx/staging/libsched.a(mq_rcvinternal.o): in function `wd_start_realtime': /home/ligd/platform/mainline/nuttx/include/nuttx/wdog.h:274: undefined reference to `clock_realtime2absticks' /home/ligd/platform/mainline/nuttx/include/nuttx/wdog.h:274:(.text+0xad): relocation truncated to fit: R_X86_64_PLT32 against undefined symbol `clock_realtime2absticks' make[1]: *** [Makefile:128: nuttx.elf] Error 1 make: *** [tools/Unix.mk:551: nuttx.elf] Error 2 Signed-off-by: ligd --- sched/clock/CMakeLists.txt | 1 + sched/clock/Make.defs | 2 +- ...time2ticks.c => clock_realtime2absticks.c} | 72 +------------------ 3 files changed, 3 insertions(+), 72 deletions(-) rename sched/clock/{clock_abstime2ticks.c => clock_realtime2absticks.c} (55%) diff --git a/sched/clock/CMakeLists.txt b/sched/clock/CMakeLists.txt index b2cf2117f8..1a6b83ce89 100644 --- a/sched/clock/CMakeLists.txt +++ b/sched/clock/CMakeLists.txt @@ -26,6 +26,7 @@ set(SRCS clock_initialize.c clock_settime.c clock_gettime.c + clock_realtime2absticks.c clock_systime_ticks.c clock_systime_timespec.c) diff --git a/sched/clock/Make.defs b/sched/clock/Make.defs index 2f306dc166..757c983f90 100644 --- a/sched/clock/Make.defs +++ b/sched/clock/Make.defs @@ -22,7 +22,7 @@ CSRCS += clock.c clock_initialize.c clock_settime.c clock_gettime.c CSRCS += clock_systime_ticks.c clock_systime_timespec.c -CSRCS += clock_perf.c +CSRCS += clock_perf.c clock_realtime2absticks.c ifeq ($(CONFIG_CLOCK_TIMEKEEPING),y) CSRCS += clock_timekeeping.c diff --git a/sched/clock/clock_abstime2ticks.c b/sched/clock/clock_realtime2absticks.c similarity index 55% rename from sched/clock/clock_abstime2ticks.c rename to sched/clock/clock_realtime2absticks.c index 6a7b3f4e86..2aedf5c942 100644 --- a/sched/clock/clock_abstime2ticks.c +++ b/sched/clock/clock_realtime2absticks.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/clock/clock_abstime2ticks.c + * sched/clock/clock_realtime2absticks.c * * SPDX-License-Identifier: Apache-2.0 * @@ -35,76 +35,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: clock_abstime2ticks - * - * Description: - * Convert an absolute timespec delay to system timer ticks. - * - * Input Parameters: - * clockid - The timing source to use in the conversion - * reltime - Convert this absolute time to system clock ticks. - * ticks - Return the converted number of ticks here. - * - * Returned Value: - * OK on success; A non-zero error number on failure - * - * Assumptions: - * Interrupts should be disabled so that the time is not changing during - * the calculation - * - ****************************************************************************/ - -int clock_abstime2ticks(clockid_t clockid, - FAR const struct timespec *abstime, - FAR sclock_t *ticks) -{ - struct timespec currtime; - struct timespec reltime; - int ret; - - /* Convert the timespec to clock ticks. - * NOTE: Here we use internal knowledge - * that CLOCK_REALTIME is defined to be zero! - */ - - ret = clock_gettime(clockid, &currtime); - if (ret != OK) - { - return ret; - } - - if (clock_timespec_compare(abstime, &currtime) < 0) - { - /* Every caller of clock_abstime2ticks check 'ticks < 0' to see if - * absolute time is in the past. So lets just return negative tick - * here. - */ - - *ticks = -1; - return OK; - } - - /* The relative time to wait is the absolute time minus the current time. */ - - reltime.tv_nsec = (abstime->tv_nsec - currtime.tv_nsec); - reltime.tv_sec = (abstime->tv_sec - currtime.tv_sec); - - /* Check if we were supposed to borrow from the seconds. */ - - if (reltime.tv_nsec < 0) - { - reltime.tv_nsec += NSEC_PER_SEC; - reltime.tv_sec -= 1; - } - - /* Convert this relative time into clock ticks. */ - - *ticks = clock_time2ticks(&reltime); - - return OK; -} - /**************************************************************************** * Name: clock_realtime2absticks *