diff --git a/libs/libc/sched/CMakeLists.txt b/libs/libc/sched/CMakeLists.txt index c447e575f20..8297eebce77 100644 --- a/libs/libc/sched/CMakeLists.txt +++ b/libs/libc/sched/CMakeLists.txt @@ -24,7 +24,6 @@ set(SRCS sched_getprioritymax.c sched_getprioritymin.c clock_getcpuclockid.c - clock_getres.c task_cancelpt.c task_setcancelstate.c task_setcanceltype.c diff --git a/libs/libc/sched/Make.defs b/libs/libc/sched/Make.defs index aa164356ddf..23aa8c0b2d5 100644 --- a/libs/libc/sched/Make.defs +++ b/libs/libc/sched/Make.defs @@ -23,9 +23,9 @@ # Add the sched C files to the build CSRCS += sched_getprioritymax.c sched_getprioritymin.c -CSRCS += clock_getcpuclockid.c clock_getres.c CSRCS += task_cancelpt.c task_setcancelstate.c task_setcanceltype.c CSRCS += task_testcancel.c task_gettid.c +CSRCS += clock_getcpuclockid.c ifeq ($(CONFIG_SMP),y) CSRCS += sched_cpucount.c diff --git a/sched/clock/CMakeLists.txt b/sched/clock/CMakeLists.txt index 62c4346bf0d..d7740ca4777 100644 --- a/sched/clock/CMakeLists.txt +++ b/sched/clock/CMakeLists.txt @@ -23,6 +23,7 @@ set(SRCS clock.c clock_initialize.c + clock_getres.c clock_settime.c clock_gettime.c clock_realtime2absticks.c diff --git a/sched/clock/Make.defs b/sched/clock/Make.defs index e61da4dbd9e..659abd6ea18 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 clock_sched_ticks.c -CSRCS += clock_perf.c clock_realtime2absticks.c +CSRCS += clock_perf.c clock_realtime2absticks.c clock_getres.c # Unless a driver with a more accurate version of up_*delay is enabled, always # include the base delay definition (busy-loop) as a minimum-viable product. We diff --git a/libs/libc/sched/clock_getres.c b/sched/clock/clock_getres.c similarity index 85% rename from libs/libc/sched/clock_getres.c rename to sched/clock/clock_getres.c index 6d373175c64..b457edc2751 100644 --- a/libs/libc/sched/clock_getres.c +++ b/sched/clock/clock_getres.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/sched/clock_getres.c + * sched/clock/clock_getres.c * * SPDX-License-Identifier: Apache-2.0 * @@ -24,14 +24,14 @@ * Included Files ****************************************************************************/ -#include - #include #include #include #include #include +#include +#include /**************************************************************************** * Public Functions @@ -74,6 +74,23 @@ int clock_getres(clockid_t clock_id, struct timespec *res) sinfo("Returning res=(%d,%d)\n", (int)res->tv_sec, (int)res->tv_nsec); break; + +#ifdef CONFIG_PTP_CLOCK + case CLOCK_FD: + { + FAR struct file *filep; + + ret = ptp_clockid_to_filep(clock_id, &filep); + if (ret < 0) + { + return ret; + } + + ret = file_ioctl(filep, PTP_CLOCK_GETRES, res); + fs_putfilep(filep); + } + break; +#endif } return ret;