diff --git a/arch/risc-v/src/bl602/bl602_os_hal.c b/arch/risc-v/src/bl602/bl602_os_hal.c index 06c06cb8f4..3f4f74134b 100644 --- a/arch/risc-v/src/bl602/bl602_os_hal.c +++ b/arch/risc-v/src/bl602/bl602_os_hal.c @@ -989,7 +989,6 @@ int bl_os_timer_start_once(void *timerid, long t_sec, long t_nsec) { struct timer_adpt *timer; struct timespec reltime; - int32_t tick; timer = (struct timer_adpt *)timerid; @@ -1001,10 +1000,8 @@ int bl_os_timer_start_once(void *timerid, long t_sec, long t_nsec) reltime.tv_nsec = t_nsec; reltime.tv_sec = t_sec; - clock_time2ticks(&reltime, &tick); - timer->mode = BL_OS_TIEMR_ONCE; - timer->delay = tick; + timer->delay = clock_time2ticks(&reltime); return wd_start(&timer->wdog, timer->delay, @@ -1027,7 +1024,6 @@ int bl_os_timer_start_periodic(void *timerid, long t_sec, long t_nsec) { struct timer_adpt *timer; struct timespec reltime; - int32_t tick; timer = (struct timer_adpt *)timerid; @@ -1039,10 +1035,8 @@ int bl_os_timer_start_periodic(void *timerid, long t_sec, long t_nsec) reltime.tv_nsec = t_nsec; reltime.tv_sec = t_sec; - clock_time2ticks(&reltime, &tick); - timer->mode = BL_OS_TIEMR_CYCLE; - timer->delay = tick; + timer->delay = clock_time2ticks(&reltime); return wd_start(&timer->wdog, timer->delay, diff --git a/drivers/timers/arch_alarm.c b/drivers/timers/arch_alarm.c index 6c39731432..33c61711fa 100644 --- a/drivers/timers/arch_alarm.c +++ b/drivers/timers/arch_alarm.c @@ -36,9 +36,6 @@ #define CONFIG_BOARD_LOOPSPER10USEC ((CONFIG_BOARD_LOOPSPERMSEC+50)/100) #define CONFIG_BOARD_LOOPSPERUSEC ((CONFIG_BOARD_LOOPSPERMSEC+500)/1000) -#define timespec_to_nsec(ts) \ - ((uint64_t)(ts)->tv_sec * NSEC_PER_SEC + (ts)->tv_nsec) - /**************************************************************************** * Private Data ****************************************************************************/ @@ -53,14 +50,6 @@ static clock_t g_current_tick; * Private Functions ****************************************************************************/ -static inline void timespec_from_nsec(FAR struct timespec *ts, - uint64_t nanoseconds) -{ - ts->tv_sec = nanoseconds / NSEC_PER_SEC; - nanoseconds -= (uint64_t)ts->tv_sec * NSEC_PER_SEC; - ts->tv_nsec = nanoseconds; -} - static void udelay_accurate(useconds_t microseconds) { struct timespec now; @@ -68,7 +57,7 @@ static void udelay_accurate(useconds_t microseconds) struct timespec delta; ONESHOT_CURRENT(g_oneshot_lower, &now); - timespec_from_nsec(&delta, (uint64_t)microseconds * NSEC_PER_USEC); + clock_nsec2time(&delta, (uint64_t)microseconds * NSEC_PER_USEC); clock_timespec_add(&now, &delta, &end); while (clock_timespec_compare(&now, &end) < 0) @@ -387,7 +376,7 @@ unsigned long up_perf_gettime(void) struct timespec ts; ONESHOT_CURRENT(g_oneshot_lower, &ts); - ret = timespec_to_nsec(&ts); + ret = clock_time2nsec(&ts); } return ret; @@ -400,7 +389,7 @@ unsigned long up_perf_getfreq(void) void up_perf_convert(unsigned long elapsed, FAR struct timespec *ts) { - timespec_from_nsec(ts, elapsed); + clock_nsec2time(ts, elapsed); } #endif /* CONFIG_ARCH_PERF_EVENTS */ diff --git a/drivers/timers/arch_timer.c b/drivers/timers/arch_timer.c index 14ebb88dfa..1f319b5717 100644 --- a/drivers/timers/arch_timer.c +++ b/drivers/timers/arch_timer.c @@ -61,14 +61,6 @@ static struct arch_timer_s g_timer; * Private Functions ****************************************************************************/ -static inline void timespec_from_usec(FAR struct timespec *ts, - uint64_t microseconds) -{ - ts->tv_sec = microseconds / USEC_PER_SEC; - microseconds -= (uint64_t)ts->tv_sec * USEC_PER_SEC; - ts->tv_nsec = microseconds * NSEC_PER_USEC; -} - #ifdef CONFIG_SCHED_TICKLESS static uint32_t update_timeout(uint32_t timeout) @@ -435,7 +427,7 @@ unsigned long up_perf_getfreq(void) void up_perf_convert(unsigned long elapsed, FAR struct timespec *ts) { - timespec_from_usec(ts, elapsed); + clock_usec2time(ts, elapsed); } #endif /* CONFIG_ARCH_PERF_EVENTS */ diff --git a/fs/vfs/fs_timerfd.c b/fs/vfs/fs_timerfd.c index 4e5433dd1c..41b6d67214 100644 --- a/fs/vfs/fs_timerfd.c +++ b/fs/vfs/fs_timerfd.c @@ -535,8 +535,8 @@ int timerfd_settime(int fd, int flags, /* Convert that to a struct timespec and return it */ - clock_ticks2time(delay, &old_value->it_value); - clock_ticks2time(dev->delay, &old_value->it_interval); + clock_ticks2time(&old_value->it_value, delay); + clock_ticks2time(&old_value->it_interval, dev->delay); } /* Disarm the timer (in case the timer was already armed when @@ -561,7 +561,7 @@ int timerfd_settime(int fd, int flags, /* Setup up any repetitive timer */ - clock_time2ticks(&new_value->it_interval, &delay); + delay = clock_time2ticks(&new_value->it_interval); dev->delay = delay; /* We need to disable timer interrupts through the following section so @@ -583,7 +583,7 @@ int timerfd_settime(int fd, int flags, * returns success. */ - clock_time2ticks(&new_value->it_value, &delay); + delay = clock_time2ticks(&new_value->it_value); } /* If the time is in the past or now, then set up the next interval @@ -651,8 +651,8 @@ int timerfd_gettime(int fd, FAR struct itimerspec *curr_value) /* Convert that to a struct timespec and return it */ - clock_ticks2time(ticks, &curr_value->it_value); - clock_ticks2time(dev->delay, &curr_value->it_interval); + clock_ticks2time(&curr_value->it_value, ticks); + clock_ticks2time(&curr_value->it_interval, dev->delay); return OK; errout: diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index 52e8bdb89c..b87a0b438a 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -325,7 +325,7 @@ EXTERN volatile clock_t g_system_ticks; * Public Function Prototypes ****************************************************************************/ -#define timespec_from_tick(ts, tick) \ +#define clock_ticks2time(ts, tick) \ do \ { \ clock_t _tick = (tick); \ @@ -335,9 +335,35 @@ EXTERN volatile clock_t g_system_ticks; } \ while (0) -#define timespec_to_tick(ts) \ +#define clock_time2ticks(ts) \ ((clock_t)(ts)->tv_sec * TICK_PER_SEC + (ts)->tv_nsec / NSEC_PER_TICK) +#define clock_usec2time(ts, usec) \ + do \ + { \ + uint64_t _usec = (usec); \ + (ts)->tv_sec = _usec / USEC_PER_SEC; \ + _usec -= (uint64_t)(ts)->tv_sec * USEC_PER_SEC; \ + (ts)->tv_nsec = _usec * NSEC_PER_USEC; \ + } \ + while (0) + +#define clock_time2usec(ts) \ + ((uint64_t)(ts)->tv_sec * USEC_PER_SEC + (ts)->tv_nsec / NSEC_PER_USEC) + +#define clock_nsec2time(ts, nsec) \ + do \ + { \ + uint64_t _nsec = (nsec); \ + (ts)->tv_sec = _nsec / NSEC_PER_SEC; \ + _nsec -= (uint64_t)(ts)->tv_sec * NSEC_PER_SEC; \ + (ts)->tv_nsec = _nsec; \ + } \ + while (0) + +#define clock_time2nsec(ts) \ + ((uint64_t)(ts)->tv_sec * NSEC_PER_SEC + (ts)->tv_nsec) + /**************************************************************************** * Name: clock_timespec_add * @@ -602,51 +628,6 @@ 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/include/nuttx/timers/oneshot.h b/include/nuttx/timers/oneshot.h index 848d517c28..14bc90183c 100644 --- a/include/nuttx/timers/oneshot.h +++ b/include/nuttx/timers/oneshot.h @@ -270,7 +270,7 @@ int oneshot_max_delay(FAR struct oneshot_lowerhalf_s *lower, DEBUGASSERT(lower->ops->tick_max_delay); ret = lower->ops->tick_max_delay(lower, &tick); - timespec_from_tick(ts, tick); + clock_ticks2time(ts, tick); return ret; } @@ -283,7 +283,7 @@ int oneshot_start(FAR struct oneshot_lowerhalf_s *lower, DEBUGASSERT(lower->ops->tick_start); - tick = timespec_to_tick(ts); + tick = clock_time2ticks(ts); return lower->ops->tick_start(lower, callback, arg, tick); } @@ -297,7 +297,7 @@ int oneshot_cancel(FAR struct oneshot_lowerhalf_s *lower, DEBUGASSERT(lower->ops->tick_cancel); ret = lower->ops->tick_cancel(lower, &tick); - timespec_from_tick(ts, tick); + clock_ticks2time(ts, tick); return ret; } @@ -312,7 +312,7 @@ int oneshot_current(FAR struct oneshot_lowerhalf_s *lower, DEBUGASSERT(lower->ops->tick_current); ret = lower->ops->tick_current(lower, &tick); - timespec_from_tick(ts, tick); + clock_ticks2time(ts, tick); return ret; } @@ -327,7 +327,7 @@ int oneshot_tick_max_delay(FAR struct oneshot_lowerhalf_s *lower, DEBUGASSERT(lower->ops->max_delay); ret = lower->ops->max_delay(lower, &ts); - *ticks = timespec_to_tick(&ts); + *ticks = clock_time2ticks(&ts); return ret; } @@ -340,7 +340,7 @@ int oneshot_tick_start(FAR struct oneshot_lowerhalf_s *lower, DEBUGASSERT(lower->ops->start); - timespec_from_tick(&ts, ticks); + clock_ticks2time(&ts, ticks); return lower->ops->start(lower, callback, arg, &ts); } @@ -354,7 +354,7 @@ int oneshot_tick_cancel(FAR struct oneshot_lowerhalf_s *lower, DEBUGASSERT(lower->ops->cancel); ret = lower->ops->cancel(lower, &ts); - *ticks = timespec_to_tick(&ts); + *ticks = clock_time2ticks(&ts); return ret; } @@ -369,7 +369,7 @@ int oneshot_tick_current(FAR struct oneshot_lowerhalf_s *lower, DEBUGASSERT(lower->ops->current); ret = lower->ops->current(lower, &ts); - *ticks = timespec_to_tick(&ts); + *ticks = clock_time2ticks(&ts); return ret; } diff --git a/libs/libc/misc/lib_mutex.c b/libs/libc/misc/lib_mutex.c index ae783a1f88..bbf960d889 100644 --- a/libs/libc/misc/lib_mutex.c +++ b/libs/libc/misc/lib_mutex.c @@ -353,7 +353,7 @@ int nxmutex_timedlock(FAR mutex_t *mutex, unsigned int timeout) struct timespec rqtp; clock_gettime(CLOCK_MONOTONIC, &now); - clock_ticks2time(MSEC2TICK(timeout), &delay); + clock_ticks2time(&delay, MSEC2TICK(timeout)); clock_timespec_add(&now, &delay, &rqtp); /* Wait until we get the lock or until the timeout expires */ diff --git a/libs/libc/sched/CMakeLists.txt b/libs/libc/sched/CMakeLists.txt index 2741130ebc..a32a324945 100644 --- a/libs/libc/sched/CMakeLists.txt +++ b/libs/libc/sched/CMakeLists.txt @@ -21,8 +21,6 @@ set(SRCS sched_getprioritymax.c sched_getprioritymin.c - clock_ticks2time.c - clock_time2ticks.c clock_getcpuclockid.c clock_getres.c task_cancelpt.c diff --git a/libs/libc/sched/Make.defs b/libs/libc/sched/Make.defs index ed0399b05b..83816fd291 100644 --- a/libs/libc/sched/Make.defs +++ b/libs/libc/sched/Make.defs @@ -21,7 +21,6 @@ # Add the sched C files to the build CSRCS += sched_getprioritymax.c sched_getprioritymin.c -CSRCS += clock_ticks2time.c clock_time2ticks.c CSRCS += clock_getcpuclockid.c clock_getres.c CSRCS += task_cancelpt.c task_setcancelstate.c task_setcanceltype.c CSRCS += task_testcancel.c diff --git a/libs/libc/sched/clock_ticks2time.c b/libs/libc/sched/clock_ticks2time.c deleted file mode 100644 index f2074bde16..0000000000 --- a/libs/libc/sched/clock_ticks2time.c +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** - * 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 - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: clock_ticks2time - * - * Description: - * Convert the system time tick value to a relative time. - * - * Input Parameters: - * ticks - The number of system time ticks to convert. - * reltime - Return the converted system time here. - * - * Returned Value: - * Always returns OK - * - * Assumptions: - * - ****************************************************************************/ - -int clock_ticks2time(sclock_t ticks, FAR struct timespec *reltime) -{ - sclock_t remainder; - - reltime->tv_sec = ticks / TICK_PER_SEC; - remainder = ticks - TICK_PER_SEC * reltime->tv_sec; - reltime->tv_nsec = remainder * NSEC_PER_TICK; - return OK; -} diff --git a/libs/libc/sched/clock_time2ticks.c b/libs/libc/sched/clock_time2ticks.c deleted file mode 100644 index 9bcf832846..0000000000 --- a/libs/libc/sched/clock_time2ticks.c +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** - * 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 - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: clock_time2ticks - * - * Description: - * Convert a timespec delay to system timer ticks. This function is - * suitable for calculating relative time delays and does not depend on - * the other clock_* logic. - * - * Input Parameters: - * reltime - Convert this relative time to system clock ticks. - * ticks - Return the converted number of ticks here. - * - * Returned Value: - * Always returns OK - * - * Assumptions: - * - ****************************************************************************/ - -int clock_time2ticks(FAR const struct timespec *reltime, - FAR sclock_t *ticks) -{ -#ifdef CONFIG_HAVE_LONG_LONG - int64_t relnsec; - - /* Convert the relative time into nanoseconds. The range of the int64_t - * is sufficiently large that there is no real need for range checking. - */ - - relnsec = (int64_t)reltime->tv_sec * NSEC_PER_SEC + - (int64_t)reltime->tv_nsec; - - /* Convert nanoseconds to clock ticks, rounding up to the smallest integer - * that is greater than or equal to the exact number of tick. - */ - - *ticks = (sclock_t)((relnsec + NSEC_PER_TICK - 1) / NSEC_PER_TICK); - return OK; -#else - int32_t relusec; - - /* This function uses an int32_t to only the relative time in microseconds. - * that means that the maximum supported relative time is 2,147,487.647 - * seconds - */ - -#if 0 // overkill - DEBUGASSERT(reltime->tv_sec < 2147487 || - reltime->tv_sec == 2147487 && - reltime->tv_nsec <= 647 * NSEC_PER_MSEC); -#endif - - /* Convert the relative time into microseconds, rounding up to the smallest - * value that is greater than or equal to the exact number of microseconds. - */ - - relusec = reltime->tv_sec * USEC_PER_SEC + - (reltime->tv_nsec + NSEC_PER_USEC - 1) / NSEC_PER_USEC; - - /* Convert microseconds to clock ticks, rounding up to the smallest integer - * that is greater than or equal to the exact number of tick. - */ - - *ticks = (sclock_t)((relusec + USEC_PER_TICK - 1) / USEC_PER_TICK); - return OK; -#endif -} diff --git a/libs/libc/wqueue/work_usrthread.c b/libs/libc/wqueue/work_usrthread.c index df31aab459..ccf942e389 100644 --- a/libs/libc/wqueue/work_usrthread.c +++ b/libs/libc/wqueue/work_usrthread.c @@ -205,7 +205,7 @@ static void work_process(FAR struct usr_wqueue_s *wqueue) */ clock_gettime(CLOCK_REALTIME, &now); - clock_ticks2time(next, &delay); + clock_ticks2time(&delay, next); clock_timespec_add(&now, &delay, &rqtp); nxsem_timedwait(&wqueue->wake, &rqtp); diff --git a/sched/clock/clock_abstime2ticks.c b/sched/clock/clock_abstime2ticks.c index 776ac6aee0..29a5af0d34 100644 --- a/sched/clock/clock_abstime2ticks.c +++ b/sched/clock/clock_abstime2ticks.c @@ -100,5 +100,7 @@ int clock_abstime2ticks(clockid_t clockid, /* Convert this relative time into clock ticks. */ - return clock_time2ticks(&reltime, ticks); + *ticks = clock_time2ticks(&reltime); + + return OK; } diff --git a/sched/clock/clock_perf.c b/sched/clock/clock_perf.c index a4c39aafb9..18393d74d1 100644 --- a/sched/clock/clock_perf.c +++ b/sched/clock/clock_perf.c @@ -190,7 +190,7 @@ clock_t perf_gettime(void) void perf_convert(clock_t elapsed, FAR struct timespec *ts) { - clock_ticks2time(elapsed, ts); + clock_ticks2time(ts, elapsed); } /**************************************************************************** diff --git a/sched/clock/clock_systime_ticks.c b/sched/clock/clock_systime_ticks.c index b0293c20da..766f7a14ca 100644 --- a/sched/clock/clock_systime_ticks.c +++ b/sched/clock/clock_systime_ticks.c @@ -92,7 +92,7 @@ clock_t clock_systime_ticks(void) * then in clock tick units. */ - return timespec_to_tick(&ts); + return clock_time2ticks(&ts); } else { @@ -120,7 +120,7 @@ clock_t clock_systime_ticks(void) struct timespec ts; if (up_timer_gettime(&ts) == OK) { - return timespec_to_tick(&ts); + return clock_time2ticks(&ts); } else { diff --git a/sched/clock/clock_systime_timespec.c b/sched/clock/clock_systime_timespec.c index c58978a96d..727b7a8bfe 100644 --- a/sched/clock/clock_systime_timespec.c +++ b/sched/clock/clock_systime_timespec.c @@ -120,7 +120,7 @@ int clock_systime_timespec(FAR struct timespec *ts) int ret; ret = up_timer_gettick(&ticks); - timespec_from_tick(ts, ticks); + clock_ticks2time(ts, ticks); return ret; #elif defined(CONFIG_SCHED_TICKLESS) return up_timer_gettime(ts); @@ -129,7 +129,7 @@ int clock_systime_timespec(FAR struct timespec *ts) * when the clock period is in units of microseconds. */ - timespec_from_tick(ts, clock_systime_ticks()); + clock_ticks2time(ts, clock_systime_ticks()); return OK; #endif } diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index 2bd4e69f72..c9cf031627 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -339,8 +339,8 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, /* Convert timespec values to system clock ticks */ - clock_time2ticks(¶m.sched_ss_repl_period, &repl_ticks); - clock_time2ticks(¶m.sched_ss_init_budget, &budget_ticks); + repl_ticks = clock_time2ticks(¶m.sched_ss_repl_period); + budget_ticks = clock_time2ticks(¶m.sched_ss_init_budget); /* The replenishment period must be greater than or equal to the * budget period. diff --git a/sched/sched/sched_getparam.c b/sched/sched/sched_getparam.c index d7016b8fe7..368546598b 100644 --- a/sched/sched/sched_getparam.c +++ b/sched/sched/sched_getparam.c @@ -123,10 +123,10 @@ int nxsched_get_param(pid_t pid, FAR struct sched_param *param) param->sched_ss_low_priority = (int)sporadic->low_priority; param->sched_ss_max_repl = (int)sporadic->max_repl; - clock_ticks2time((sclock_t)sporadic->repl_period, - ¶m->sched_ss_repl_period); - clock_ticks2time((sclock_t)sporadic->budget, - ¶m->sched_ss_init_budget); + clock_ticks2time(¶m->sched_ss_repl_period, + sporadic->repl_period); + clock_ticks2time(¶m->sched_ss_init_budget, + sporadic->budget); } else { diff --git a/sched/sched/sched_setparam.c b/sched/sched/sched_setparam.c index c1184fd96a..97c76696d4 100644 --- a/sched/sched/sched_setparam.c +++ b/sched/sched/sched_setparam.c @@ -136,8 +136,8 @@ int nxsched_set_param(pid_t pid, FAR const struct sched_param *param) /* Convert timespec values to system clock ticks */ - clock_time2ticks(¶m->sched_ss_repl_period, &repl_ticks); - clock_time2ticks(¶m->sched_ss_init_budget, &budget_ticks); + repl_ticks = clock_time2ticks(¶m->sched_ss_repl_period); + budget_ticks = clock_time2ticks(¶m->sched_ss_init_budget); /* Avoid zero/negative times */ diff --git a/sched/sched/sched_setscheduler.c b/sched/sched/sched_setscheduler.c index 536518fdf3..8bfb7de77a 100644 --- a/sched/sched/sched_setscheduler.c +++ b/sched/sched/sched_setscheduler.c @@ -192,8 +192,8 @@ int nxsched_set_scheduler(pid_t pid, int policy, /* Convert timespec values to system clock ticks */ - clock_time2ticks(¶m->sched_ss_repl_period, &repl_ticks); - clock_time2ticks(¶m->sched_ss_init_budget, &budget_ticks); + repl_ticks = clock_time2ticks(¶m->sched_ss_repl_period); + budget_ticks = clock_time2ticks(¶m->sched_ss_init_budget); /* Avoid zero/negative times */ diff --git a/sched/sched/sched_timerexpiration.c b/sched/sched/sched_timerexpiration.c index 7072312449..a215f04999 100644 --- a/sched/sched/sched_timerexpiration.c +++ b/sched/sched/sched_timerexpiration.c @@ -112,7 +112,7 @@ int up_timer_gettick(FAR clock_t *ticks) struct timespec ts; int ret; ret = up_timer_gettime(&ts); - *ticks = timespec_to_tick(&ts); + *ticks = clock_time2ticks(&ts); return ret; } #endif @@ -122,7 +122,7 @@ int up_timer_gettick(FAR clock_t *ticks) int up_alarm_tick_start(clock_t ticks) { struct timespec ts; - timespec_from_tick(&ts, ticks); + clock_ticks2time(&ts, ticks); return up_alarm_start(&ts); } @@ -131,14 +131,14 @@ int up_alarm_tick_cancel(FAR clock_t *ticks) struct timespec ts; int ret; ret = up_alarm_cancel(&ts); - *ticks = timespec_to_tick(&ts); + *ticks = clock_time2ticks(&ts); return ret; } # else int up_timer_tick_start(clock_t ticks) { struct timespec ts; - timespec_from_tick(&ts, ticks); + clock_ticks2time(&ts, ticks); return up_timer_start(&ts); } @@ -147,7 +147,7 @@ int up_timer_tick_cancel(FAR clock_t *ticks) struct timespec ts; int ret; ret = up_timer_cancel(&ts); - *ticks = timespec_to_tick(&ts); + *ticks = clock_time2ticks(&ts); return ret; } # endif @@ -474,7 +474,7 @@ void nxsched_alarm_expiration(FAR const struct timespec *ts) DEBUGASSERT(ts); - ticks = timespec_to_tick(ts); + ticks = clock_time2ticks(ts); nxsched_alarm_tick_expiration(ticks); } #endif diff --git a/sched/signal/sig_nanosleep.c b/sched/signal/sig_nanosleep.c index b4f3c2d7ba..3c8c3c6886 100644 --- a/sched/signal/sig_nanosleep.c +++ b/sched/signal/sig_nanosleep.c @@ -174,7 +174,7 @@ int nxsig_nanosleep(FAR const struct timespec *rqtp, * wait. */ - clock_time2ticks(rqtp, &ticks); + ticks = clock_time2ticks(rqtp); /* Get the number of ticks that we actually waited */ @@ -194,7 +194,7 @@ int nxsig_nanosleep(FAR const struct timespec *rqtp, remaining = (clock_t)ticks - elapsed; } - clock_ticks2time((sclock_t)remaining, rmtp); + clock_ticks2time(rmtp, remaining); } leave_critical_section(flags); diff --git a/sched/timer/timer_gettime.c b/sched/timer/timer_gettime.c index c6a2b7660d..322460cd7e 100644 --- a/sched/timer/timer_gettime.c +++ b/sched/timer/timer_gettime.c @@ -87,8 +87,8 @@ int timer_gettime(timer_t timerid, FAR struct itimerspec *value) /* Convert that to a struct timespec and return it */ - clock_ticks2time(ticks, &value->it_value); - clock_ticks2time(timer->pt_delay, &value->it_interval); + clock_ticks2time(&value->it_value, ticks); + clock_ticks2time(&value->it_interval, timer->pt_delay); return OK; } diff --git a/sched/timer/timer_settime.c b/sched/timer/timer_settime.c index 528d34279e..1db3bbcfb5 100644 --- a/sched/timer/timer_settime.c +++ b/sched/timer/timer_settime.c @@ -244,8 +244,8 @@ int timer_settime(timer_t timerid, int flags, /* Convert that to a struct timespec and return it */ - clock_ticks2time(delay, &ovalue->it_value); - clock_ticks2time(timer->pt_delay, &ovalue->it_interval); + clock_ticks2time(&ovalue->it_value, delay); + clock_ticks2time(&ovalue->it_interval, timer->pt_delay); } /* Disarm the timer (in case the timer was already armed when @@ -271,7 +271,7 @@ int timer_settime(timer_t timerid, int flags, if (value->it_interval.tv_sec > 0 || value->it_interval.tv_nsec > 0) { - clock_time2ticks(&value->it_interval, &delay); + delay = clock_time2ticks(&value->it_interval); /* REVISIT: Should pt_delay be sclock_t? */ @@ -303,7 +303,7 @@ int timer_settime(timer_t timerid, int flags, * returns success. */ - ret = clock_time2ticks(&value->it_value, &delay); + delay = clock_time2ticks(&value->it_value); } if (ret < 0)