diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index b11b1cfc693..7790f681008 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -394,6 +394,51 @@ void clock_resynchronize(FAR struct timespec *rtc_diff); clock_t clock_systime_ticks(void); #endif +/**************************************************************************** + * Name: clock_time2ticks + * + * Description: + * Return the given struct timespec as systime ticks. + * + * NOTE: This is an internal OS interface and should not be called from + * application code. + * + * Input Parameters: + * reltime - Pointer to the time presented as struct timespec + * + * Output Parameters: + * ticks - Pointer to receive the time value presented as systime ticks + * + * Returned Value: + * Always returns OK (0) + * + ****************************************************************************/ + +int clock_time2ticks(FAR const struct timespec *reltime, + FAR sclock_t *ticks); + +/**************************************************************************** + * Name: clock_ticks2time + * + * Description: + * Return the given systime ticks as a struct timespec. + * + * NOTE: This is an internal OS interface and should not be called from + * application code. + * + * Input Parameters: + * ticks - Time presented as systime ticks + * + * Output Parameters: + * reltime - Pointer to receive the time value presented as struct timespec + * + * Returned Value: + * Always returns OK (0) + * + ****************************************************************************/ + +int clock_ticks2time(sclock_t ticks, FAR struct timespec *reltime); + /**************************************************************************** * Name: clock_systime_timespec * diff --git a/libs/libc/sched/Make.defs b/libs/libc/sched/Make.defs index 690d871ec77..a136f4834e8 100644 --- a/libs/libc/sched/Make.defs +++ b/libs/libc/sched/Make.defs @@ -21,6 +21,8 @@ # Add the sched C files to the build CSRCS += sched_getprioritymax.c sched_getprioritymin.c +CSRCS += clock_ticks2time.c clock_time2ticks.c +CSRCS += clock_timespec_add.c clock_timespec_subtract.c ifneq ($(CONFIG_CANCELLATION_POINTS),y) CSRCS += task_setcanceltype.c task_testcancel.c diff --git a/sched/clock/clock_ticks2time.c b/libs/libc/sched/clock_ticks2time.c similarity index 97% rename from sched/clock/clock_ticks2time.c rename to libs/libc/sched/clock_ticks2time.c index 9cb08a87f0b..f2074bde16d 100644 --- a/sched/clock/clock_ticks2time.c +++ b/libs/libc/sched/clock_ticks2time.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/clock/clock_ticks2time.c + * libs/libc/sched/clock_ticks2time.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -25,7 +25,7 @@ #include #include -#include "clock/clock.h" +#include /**************************************************************************** * Public Functions diff --git a/sched/clock/clock_time2ticks.c b/libs/libc/sched/clock_time2ticks.c similarity index 98% rename from sched/clock/clock_time2ticks.c rename to libs/libc/sched/clock_time2ticks.c index 72e5f7942aa..9bcf832846d 100644 --- a/sched/clock/clock_time2ticks.c +++ b/libs/libc/sched/clock_time2ticks.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/clock/clock_time2ticks.c + * libs/libc/sched/clock_time2ticks.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -28,7 +28,7 @@ #include #include -#include "clock/clock.h" +#include /**************************************************************************** * Public Functions diff --git a/sched/clock/clock_timespec_add.c b/libs/libc/sched/clock_timespec_add.c similarity index 97% rename from sched/clock/clock_timespec_add.c rename to libs/libc/sched/clock_timespec_add.c index 17fa47f66d8..04d8234828b 100644 --- a/sched/clock/clock_timespec_add.c +++ b/libs/libc/sched/clock_timespec_add.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/clock/clock_timespec_add.c + * libs/libc/sched/clock_timespec_add.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -27,7 +27,7 @@ #include #include -#include "clock/clock.h" +#include /**************************************************************************** * Public Functions diff --git a/sched/clock/clock_timespec_subtract.c b/libs/libc/sched/clock_timespec_subtract.c similarity index 97% rename from sched/clock/clock_timespec_subtract.c rename to libs/libc/sched/clock_timespec_subtract.c index 04d378ef4fb..1cfd599903c 100644 --- a/sched/clock/clock_timespec_subtract.c +++ b/libs/libc/sched/clock_timespec_subtract.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/clock/clock_timespec_subtract.c + * libs/libc/sched/clock_timespec_subtract.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -27,7 +27,7 @@ #include #include -#include "clock/clock.h" +#include /**************************************************************************** * Public Functions diff --git a/sched/clock/Make.defs b/sched/clock/Make.defs index 57a51b6b221..7ae14e7a015 100644 --- a/sched/clock/Make.defs +++ b/sched/clock/Make.defs @@ -19,9 +19,9 @@ ############################################################################ CSRCS += clock_initialize.c clock_settime.c clock_gettime.c clock_getres.c -CSRCS += clock_time2ticks.c clock_abstime2ticks.c clock_ticks2time.c -CSRCS += clock_systime_ticks.c clock_systime_timespec.c clock_timespec_add.c -CSRCS += clock_timespec_subtract.c clock.c +CSRCS += clock_abstime2ticks.c +CSRCS += clock_systime_ticks.c clock_systime_timespec.c +CSRCS += clock.c ifeq ($(CONFIG_CLOCK_TIMEKEEPING),y) CSRCS += clock_timekeeping.c diff --git a/sched/clock/clock.h b/sched/clock/clock.h index 874edc2a315..3f67f0fcc24 100644 --- a/sched/clock/clock.h +++ b/sched/clock/clock.h @@ -84,8 +84,5 @@ void weak_function clock_timer(void); int clock_abstime2ticks(clockid_t clockid, FAR const struct timespec *abstime, FAR sclock_t *ticks); -int clock_time2ticks(FAR const struct timespec *reltime, - FAR sclock_t *ticks); -int clock_ticks2time(sclock_t ticks, FAR struct timespec *reltime); #endif /* __SCHED_CLOCK_CLOCK_H */