!sys/types.h: change time_t and clock_t to int64_t to align with other OSes

POSIX leaves the signedness of time_t and clock_t unspecified, but
mainstream implementations (Linux glibc/musl, the BSDs, macOS, RTEMS,
Zephyr's POSIX layer, Windows _time64) expose time_t as signed 64-bit.
NuttX has historically used uint64_t only because it was tied to the
CONFIG_SYSTEM_TIME64 knob; with that gone, switch:

  time_t   : uint64_t  -> int64_t
  clock_t  : uint64_t  -> int64_t
  CLOCK_MAX: UINT64_MAX -> INT64_MAX

This lets (time_t)-1 sentinels, negative tick deltas, and host-side
headers behave as on every other POSIX system without source churn.

Headers updated:
  - include/sys/types.h, include/limits.h, include/nuttx/clock.h
  - include/nuttx/fs/hostfs.h (nuttx_time_t alias)
  - include/nuttx/{mqueue.h,wdog.h,wqueue.h,timers/clkcnt.h}

Because clock_t is now signed 64-bit, the NuttX-internal sclock_t
alias becomes redundant: every sclock_t/SCLOCK_MAX use is folded
back to clock_t/CLOCK_MAX (notably in sched/wdog, sched/mqueue,
sched/sched, sched/clock, sched/timer, libs/libc/time, fs/vfs and
the drivers/arch consumers below).

Tick/period constants (NSEC_PER_SEC, USEC_PER_SEC, MSEC_PER_SEC,
SEC_PER_MIN, ...) in include/nuttx/clock.h are retyped from "long"
literals to INT64_C(...) so that 64-bit arithmetic no longer
depends on the host's long width.

Strip now-redundant (time_t)/(clock_t)/(unsigned long) casts and
unsigned-only branches across the tree:
  - arch RTC / oneshot / tickless lowerhalfs:
      arm: cxd56xx, efm32, imxrt, lc823450, max326xx, sam34, sama5,
           samd5e5, samv7, stm32, stm32f7, stm32h7, stm32l4, stm32wb,
           xmc4
      mips: pic32mz       sparc: bm3803       x86_64: intel64
      risc-v/xtensa: espressif (esp_i2c[_slave], esp_rtc,
           esp32c3{_i2c,_rtc,_wifi_adapter}, esp32{,s2,s3}_*),
           mpfs_perf
  - drivers: audio/tone, input/aw86225, power/pm/{activity,
           stability}_governor, rpmsg/rpmsg_ping,
           timers/{ds3231,mcp794xx,pcf85263,rx8010},
           wireless/ieee80211/bcm43xxx, wireless/spirit/spirit_spi
  - core: fs/vfs/{fs_poll,fs_timerfd}, mm/iob/iob_alloc,
          libs/libc/{netdb/lib_dnscache,time/{lib_calendar2utc,
          lib_time}}, net/icmp/icmp_pmtu, net/icmpv6/icmpv6_pmtu,
          net/ipfrag, net/tcp/{tcp.h,tcp_timer},
          net/utils/net_snoop, net/mld/mld_query (drop the now-dead
          mld_mrc2mrd helper since signed math handles it directly),
          sched/clock/{clock,clock_initialize},
          sched/sched/{sched_profil,sched_setparam,sched_setscheduler},
          sched/pthread/pthread_create,
          sched/wdog/{wd_gettime,wd_start,wdog.h},
          sched/timer/timer_gettime, sched/mqueue/*

Flip the few in-tree printf format strings that assumed an
unsigned 64-bit tv_sec:
  * drivers/rpmsg/rpmsg_ping.c                       PRIu64 -> PRId64
  * arch/xtensa/src/esp32{,s2,s3}/esp32*_oneshot_lowerhalf.c
                                          PRIu32 (already wrong) -> PRId64

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2026-05-03 16:48:08 +08:00 committed by Xiang Xiao
parent c6654b1106
commit c47b1e2c5b
94 changed files with 207 additions and 262 deletions

View file

@ -394,7 +394,7 @@ time_t up_rtc_time(void)
count += g_rtc_save->offset;
count >>= 15; /* convert to 1sec resolution */
return (time_t)count / CONFIG_RTC_FREQUENCY;
return count / CONFIG_RTC_FREQUENCY;
}
#endif

View file

@ -398,7 +398,7 @@ int up_rtc_initialize(void)
#ifndef CONFIG_RTC_HIRES
time_t up_rtc_time(void)
{
return (time_t)efm32_get_burtc_tick() / CONFIG_RTC_FREQUENCY;
return efm32_get_burtc_tick() / CONFIG_RTC_FREQUENCY;
}
#endif

View file

@ -463,7 +463,7 @@ static int imxrt_rdalarm(struct rtc_lowerhalf_s *lower,
/* Get the current alarm setting in seconds */
alarm = (time_t)imxrt_hprtc_getalarm();
alarm = imxrt_hprtc_getalarm();
/* Convert the one second epoch time to a struct tm */

View file

@ -173,7 +173,7 @@ static void tm_divider(struct tm *tm, int divn, int divm)
{
time_t tt;
tt = timegm(tm);
tt = (time_t) ((uint64_t)tt * divn / divm);
tt = tt * divn / divm;
gmtime_r(&tt, tm);
}
#endif /* CONFIG_RTC_DIV */

View file

@ -724,8 +724,8 @@ int up_rtc_gettime(struct timespec *tp)
/* And return the result to the caller. */
tp->tv_sec = (time_t)secs;
tp->tv_nsec = (long)nsecs;
tp->tv_sec = secs;
tp->tv_nsec = nsecs;
tmrinfo("Returning tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec);
return OK;

View file

@ -581,7 +581,7 @@ static int max326_rdalarm(struct rtc_lowerhalf_s *lower,
{
/* Extract integer seconds from the b32_t value */
time_t sec = (time_t)(b32toi(ftime));
time_t sec = b32toi(ftime);
/* Convert to struct rtc_time (aka struct tm) */

View file

@ -496,8 +496,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -152,8 +152,8 @@ static int sam_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -507,8 +507,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -154,8 +154,8 @@ static int sam_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -441,8 +441,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -152,8 +152,8 @@ static int sam_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -506,8 +506,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -152,8 +152,8 @@ static int sam_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -445,8 +445,8 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -151,8 +151,8 @@ static int stm32_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -710,7 +710,7 @@ int up_timer_gettime(struct timespec *ts)
int up_timer_gettick(clock_t *ticks)
{
*ticks = (clock_t)STM32_TIM_GETCOUNTER(g_tickless.tch);
*ticks = STM32_TIM_GETCOUNTER(g_tickless.tch);
return OK;
}
@ -869,8 +869,8 @@ int up_timer_cancel(struct timespec *ts)
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);

View file

@ -751,7 +751,7 @@ int up_timer_gettime(struct timespec *ts)
int up_timer_gettick(clock_t *ticks)
{
*ticks = (clock_t)STM32_TIM_GETCOUNTER(g_tickless.tch);
*ticks = STM32_TIM_GETCOUNTER(g_tickless.tch);
return OK;
}
@ -911,8 +911,8 @@ int up_timer_cancel(struct timespec *ts)
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);

View file

@ -151,8 +151,8 @@ static int stm32_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -725,7 +725,7 @@ int up_timer_gettime(struct timespec *ts)
int up_timer_gettick(clock_t *ticks)
{
*ticks = (clock_t)STM32_TIM_GETCOUNTER(g_tickless.tch);
*ticks = STM32_TIM_GETCOUNTER(g_tickless.tch);
return OK;
}
@ -885,8 +885,8 @@ int up_timer_cancel(struct timespec *ts)
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);

View file

@ -447,8 +447,8 @@ int stm32l4_oneshot_cancel(struct stm32l4_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -152,8 +152,8 @@ static int stm32l4_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -446,8 +446,8 @@ int stm32wb_oneshot_cancel(struct stm32wb_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -152,8 +152,8 @@ static int stm32wb_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -576,7 +576,7 @@ int up_timer_gettime(struct timespec *ts)
int up_timer_gettick(clock_t *ticks)
{
*ticks = (clock_t)STM32WB_TIM_GETCOUNTER(g_tickless.tch);
*ticks = STM32WB_TIM_GETCOUNTER(g_tickless.tch);
return OK;
}
@ -735,8 +735,8 @@ int up_timer_cancel(struct timespec *ts)
sec = usec / USEC_PER_SEC;
nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);

View file

@ -563,8 +563,8 @@ int up_timer_cancel(struct timespec *ts)
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining count : %lu (%lu, %lu)\n", count,
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);

View file

@ -301,7 +301,7 @@ static void avrdx_check_alarm_expired(uint8_t context)
/* Note about data types - struct timespec is defined
* in include/time.h, tv_sec is of type time_t which is defined
* in include/sys/types.h as uint64_t.
* in include/sys/types.h as int64_t.
*
* tv_nsec is defined as long, signed value
*/

View file

@ -433,8 +433,8 @@ int pic32mz_oneshot_cancel(struct pic32mz_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -153,8 +153,8 @@ static int pic32mz_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -1052,7 +1052,7 @@ static int esp_i2c_polling_waitdone(struct esp_i2c_priv_s *priv)
* and an error didn't occur within the timeout
*/
while ((sclock_t)(current - timeout) < 0 && (priv->error == 0))
while (current - timeout < 0 && priv->error == 0)
{
/* Check if any interrupt triggered, clear them
* process the operation.

View file

@ -679,7 +679,7 @@ static int esp_i2c_slave_polling_waitdone(struct esp_i2c_priv_s *priv)
current = clock_systime_ticks();
timeout = current + SEC2TICK(I2C_SLAVE_POLL_RATE);
while ((sclock_t)(current - timeout) < 0)
while (current - timeout < 0)
{
/* Check if any interrupt triggered, clear them
* process the operation.

View file

@ -699,7 +699,7 @@ time_t up_rtc_time(void)
spin_unlock_irqrestore(&g_rtc_lowerhalf.lock, flags);
return (time_t)(time_us / USEC_PER_SEC);
return time_us / USEC_PER_SEC;
}
#endif /* !CONFIG_RTC_HIRES */

View file

@ -846,7 +846,7 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv)
* and an error didn't occur within the timeout
*/
while ((sclock_t)(current - timeout) < 0 && (priv->error == 0))
while (current - timeout < 0 && priv->error == 0)
{
/* Check if any interrupt triggered, clear them
* process the operation.

View file

@ -3108,7 +3108,7 @@ time_t up_rtc_time(void)
spin_unlock_irqrestore(&g_rtc_lock, flags);
return (time_t)(time_us / USEC_PER_SEC);
return time_us / USEC_PER_SEC;
}
#endif /* !CONFIG_RTC_HIRES */

View file

@ -3289,8 +3289,8 @@ static int esp_get_time(void *t)
ret = gettimeofday(&tv, NULL);
if (!ret)
{
time_adpt->sec = (time_t)tv.tv_sec;
time_adpt->usec = (suseconds_t)tv.tv_usec;
time_adpt->sec = tv.tv_sec;
time_adpt->usec = tv.tv_usec;
}
else
{

View file

@ -90,7 +90,7 @@ void up_udelay(useconds_t microseconds)
{
clock_t start = up_perf_gettime();
clock_t end = microseconds * up_perf_getfreq() / USEC_PER_SEC + start + 1;
while (((sclock_t)(up_perf_gettime() - end)) < 0)
while (up_perf_gettime() - end < 0)
{
}
}

View file

@ -389,8 +389,8 @@ int bm3803_oneshot_cancel(struct bm3803_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",

View file

@ -154,8 +154,8 @@ static int bm3803_max_delay(struct oneshot_lowerhalf_s *lower,
uint64_t sec = usecs / 1000000;
usecs -= 1000000 * sec;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (long)(usecs * 1000);
ts->tv_sec = sec;
ts->tv_nsec = usecs * 1000;
}
return ret;

View file

@ -461,8 +461,8 @@ int intel64_oneshot_cancel(struct intel64_oneshot_s *oneshot,
sec = usec / USEC_PER_SEC;
nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts->tv_sec = (time_t)sec;
ts->tv_nsec = (unsigned long)nsec;
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);

View file

@ -694,7 +694,7 @@ static int esp_i2c_slave_polling_waitdone(struct esp_i2c_priv_s *priv)
current = clock_systime_ticks();
timeout = current + SEC2TICK(I2C_SLAVE_POLL_RATE);
while ((sclock_t)(current - timeout) < 0)
while (current - timeout < 0)
{
/* Check if any interrupt triggered, clear them
* process the operation.

View file

@ -698,7 +698,7 @@ time_t up_rtc_time(void)
spin_unlock_irqrestore(&g_rtc_lowerhalf.lock, flags);
return (time_t)(time_us / USEC_PER_SEC);
return time_us / USEC_PER_SEC;
}
#endif /* !CONFIG_RTC_HIRES */

View file

@ -154,7 +154,7 @@ static int esp32_max_lh_delay(struct oneshot_lowerhalf_s *lower,
ts->tv_sec = UINT32_MAX;
ts->tv_nsec = NSEC_PER_SEC - 1;
tmrinfo("max sec=%" PRIu32 "\n", ts->tv_sec);
tmrinfo("max sec=%" PRId64 "\n", ts->tv_sec);
tmrinfo("max nsec=%" PRId32 "\n", ts->tv_nsec);
return OK;

View file

@ -2594,8 +2594,8 @@ static int esp_get_time(void *t)
ret = gettimeofday(&tv, NULL);
if (!ret)
{
time_adpt->sec = (time_t)tv.tv_sec;
time_adpt->usec = (suseconds_t)tv.tv_usec;
time_adpt->sec = tv.tv_sec;
time_adpt->usec = tv.tv_usec;
}
else
{

View file

@ -155,7 +155,7 @@ static int oneshot_lh_max_delay(struct oneshot_lowerhalf_s *lower,
ts->tv_sec = UINT32_MAX;
ts->tv_nsec = NSEC_PER_SEC - 1;
tmrinfo("max sec=%" PRIu32 "\n", ts->tv_sec);
tmrinfo("max sec=%" PRId64 "\n", ts->tv_sec);
tmrinfo("max nsec=%ld\n", ts->tv_nsec);
return OK;

View file

@ -2412,8 +2412,8 @@ static int esp_get_time(void *t)
ret = gettimeofday(&tv, NULL);
if (!ret)
{
time_adpt->sec = (time_t)tv.tv_sec;
time_adpt->usec = (suseconds_t)tv.tv_usec;
time_adpt->sec = tv.tv_sec;
time_adpt->usec = tv.tv_usec;
}
else
{

View file

@ -155,7 +155,7 @@ static int oneshot_lh_max_delay(struct oneshot_lowerhalf_s *lower,
ts->tv_sec = UINT32_MAX;
ts->tv_nsec = NSEC_PER_SEC - 1;
tmrinfo("max sec=%" PRIu32 "\n", ts->tv_sec);
tmrinfo("max sec=%" PRId64 "\n", ts->tv_sec);
tmrinfo("max nsec=%ld\n", ts->tv_nsec);
return OK;

View file

@ -2584,8 +2584,8 @@ static int esp_get_time(void *t)
ret = gettimeofday(&tv, NULL);
if (!ret)
{
time_adpt->sec = (time_t)tv.tv_sec;
time_adpt->usec = (suseconds_t)tv.tv_usec;
time_adpt->sec = tv.tv_sec;
time_adpt->usec = tv.tv_usec;
}
else
{

View file

@ -377,8 +377,8 @@ static void next_note(FAR struct tone_upperhalf_s *upper)
sec = duration / USEC_PER_SEC;
nsec = ((duration) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts.tv_sec = (time_t) sec;
ts.tv_nsec = (unsigned long)nsec;
ts.tv_sec = sec;
ts.tv_nsec = nsec;
ONESHOT_START(upper->oneshot, &ts);
@ -511,8 +511,8 @@ static void next_note(FAR struct tone_upperhalf_s *upper)
sec = duration / USEC_PER_SEC;
nsec = ((duration) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts.tv_sec = (time_t) sec;
ts.tv_nsec = (unsigned long)nsec;
ts.tv_sec = sec;
ts.tv_nsec = nsec;
ONESHOT_START(upper->oneshot, &ts);
return;
@ -554,8 +554,8 @@ static void next_note(FAR struct tone_upperhalf_s *upper)
sec = duration / USEC_PER_SEC;
nsec = ((duration) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts.tv_sec = (time_t) sec;
ts.tv_nsec = (unsigned long)nsec;
ts.tv_sec = sec;
ts.tv_nsec = nsec;
ONESHOT_START(upper->oneshot, &ts);
@ -636,8 +636,8 @@ static void next_note(FAR struct tone_upperhalf_s *upper)
sec = duration / USEC_PER_SEC;
nsec = ((duration) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
ts.tv_sec = (time_t) sec;
ts.tv_nsec = (unsigned long)nsec;
ts.tv_sec = sec;
ts.tv_nsec = nsec;
/* And arrange a callback when the note should stop */

View file

@ -2144,7 +2144,7 @@ static int aw86225_haptics_upload_effect(FAR struct ff_lowerhalf_s *lower,
FAR struct aw86225 *aw86225 = (FAR struct aw86225 *)lower;
FAR struct aw86225_hap_play_info *play = &aw86225->play;
int16_t data[AW86225_CUSTOM_DATA_LEN];
sclock_t time_us;
clock_t time_us;
int ret;
time_us = wd_gettime(&aw86225->timer);

View file

@ -573,10 +573,10 @@ static void governor_timer(int domain, enum pm_state_e newstate)
if (newstate < PM_SLEEP && dq_empty(&pdom->wakelock[newstate]))
{
sclock_t delay = pmtick[newstate] +
pdomstate->btime -
clock_systime_ticks();
sclock_t left = wd_gettime(&pdomstate->wdog);
clock_t delay = pmtick[newstate] +
pdomstate->btime -
clock_systime_ticks();
clock_t left = wd_gettime(&pdomstate->wdog);
if (delay <= 0)
{

View file

@ -115,7 +115,7 @@ static void stability_governor_statechanged(int domain,
{
if (WDOG_ISACTIVE(&g_stability_governor.domain[domain].wdog))
{
sclock_t left;
clock_t left;
/* The left tick from wdog, if >0 should be other irq source */

View file

@ -189,7 +189,7 @@ static void rpmsg_ping_logout(FAR const char *s, clock_t value)
perf_convert(value, &ts);
syslog(LOG_EMERG, "%s: %" PRIu64 " s, %ld ns\n", s, ts.tv_sec, ts.tv_nsec);
syslog(LOG_EMERG, "%s: %" PRId64 " s, %ld ns\n", s, ts.tv_sec, ts.tv_nsec);
}
static void rpmsg_ping_logout_rate(uint64_t len, clock_t avg)

View file

@ -409,7 +409,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
/* Get the broken out time */
newtime = (time_t)tp->tv_sec;
newtime = tp->tv_sec;
if (tp->tv_nsec >= 500000000)
{
/* Round up */

View file

@ -502,7 +502,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
/* Get the broken out time */
newtime = (time_t)tp->tv_sec;
newtime = tp->tv_sec;
if (tp->tv_nsec >= 500000000)
{
/* Round up */

View file

@ -392,7 +392,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
/* Get the broken out time */
newtime = (time_t)tp->tv_sec;
newtime = tp->tv_sec;
if (tp->tv_nsec >= 500000000)
{
/* Round up */

View file

@ -397,7 +397,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
/* Get the broken out time */
newtime = (time_t)tp->tv_sec;
newtime = tp->tv_sec;
if (tp->tv_nsec >= 500000000)
{
/* Round up */

View file

@ -106,7 +106,7 @@ struct bcmf_dev_s
struct work_s lp_work_ifdown; /* Ifdown work to work queue */
struct work_s lp_work_dtim; /* Low power work to work queue */
int lp_dtim; /* Listen interval Delivery Traffic Indication Message */
sclock_t lp_ticks; /* Ticks of last tx time */
clock_t lp_ticks; /* Ticks of last tx time */
#endif
#ifdef CONFIG_IEEE80211_BROADCOM_PTA_PRIORITY
int pta_priority; /* Current priority of Packet Traffic Arbitration */

View file

@ -635,17 +635,9 @@ int spirit_waitstatus(FAR struct spirit_library_s *spirit,
/* Convert the MSEC timedelay to clock ticks, making sure that the
* resulting delay in ticks is greater than or equal to the requested time
* in MSEC.
*
* REVISIT: If USEC_PER_TICK and 'msec' are large, then the second
* computation may overflow!
*/
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
ticks = (msec + (MSEC_PER_TICK - 1)) / MSEC_PER_TICK;
#else
ticks = ((clock_t)msec * USEC_PER_MSEC + (USEC_PER_TICK - 1)) /
USEC_PER_TICK;
#endif
ticks = MSEC2TICK(msec);
/* The time that we started the wait */

View file

@ -488,7 +488,7 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
* will return immediately.
*/
ret = nxsem_tickwait(&sem, MSEC2TICK((clock_t)timeout));
ret = nxsem_tickwait(&sem, MSEC2TICK(timeout));
if (ret < 0)
{
if (ret == -ETIMEDOUT)

View file

@ -654,7 +654,7 @@ int timerfd_settime(int fd, int flags,
* instead (assuming a repetitive timer).
*/
if ((sclock_t)delay <= 0)
if (delay <= 0)
{
delay = dev->delay;
}
@ -692,7 +692,7 @@ int timerfd_gettime(int fd, FAR struct itimerspec *curr_value)
{
FAR struct timerfd_priv_s *dev;
FAR struct file *filep;
sclock_t ticks;
clock_t ticks;
int ret;
/* Some sanity checks */

View file

@ -236,7 +236,7 @@
#define TIMER_MAX _POSIX_TIMER_MAX
#define CLOCKRES_MIN _POSIX_CLOCKRES_MIN
#define CLOCK_MAX UINT64_MAX
#define CLOCK_MAX INT64_MAX
/* Other invariant values */

View file

@ -177,11 +177,11 @@
/* ?SEC2TIC rounds up */
#define NSEC2TICK(nsec) div_const_roundup(nsec, (uint32_t)NSEC_PER_TICK)
#define USEC2TICK(usec) div_const_roundup(usec, (uint32_t)USEC_PER_TICK)
#define NSEC2TICK(nsec) div_const_roundup(nsec, NSEC_PER_TICK)
#define USEC2TICK(usec) div_const_roundup(usec, USEC_PER_TICK)
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
# define MSEC2TICK(msec) div_const_roundup(msec, (uint32_t)MSEC_PER_TICK)
# define MSEC2TICK(msec) div_const_roundup(msec, MSEC_PER_TICK)
#else
# define MSEC2TICK(msec) USEC2TICK((msec) * USEC_PER_MSEC)
#endif
@ -196,34 +196,34 @@
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
# define TICK2MSEC(tick) ((tick) * MSEC_PER_TICK)
#else
# define TICK2MSEC(tick) div_const(((tick) * USEC_PER_TICK), (uint32_t)USEC_PER_MSEC)
# define TICK2MSEC(tick) div_const(((tick) * USEC_PER_TICK), USEC_PER_MSEC)
#endif
/* TIC2?SEC rounds to nearest */
#define TICK2DSEC(tick) div_const_roundnearest(tick, (uint32_t)TICK_PER_DSEC)
#define TICK2HSEC(tick) div_const_roundnearest(tick, (uint32_t)TICK_PER_HSEC)
#define TICK2SEC(tick) div_const_roundnearest(tick, (uint32_t)TICK_PER_SEC)
#define TICK2DSEC(tick) div_const_roundnearest(tick, TICK_PER_DSEC)
#define TICK2HSEC(tick) div_const_roundnearest(tick, TICK_PER_HSEC)
#define TICK2SEC(tick) div_const_roundnearest(tick, TICK_PER_SEC)
/* MSEC2SEC */
#define MSEC2SEC(usec) div_const(msec, (uint32_t)MSEC_PER_SEC)
#define MSEC2SEC(msec) div_const(msec, MSEC_PER_SEC)
/* USEC2MSEC */
#define USEC2MSEC(usec) div_const(usec, (uint32_t)USEC_PER_MSEC)
#define USEC2MSEC(usec) div_const(usec, USEC_PER_MSEC)
/* USEC2SEC */
#define USEC2SEC(usec) div_const(usec, (uint32_t)USEC_PER_SEC)
#define USEC2SEC(usec) div_const(usec, USEC_PER_SEC)
/* NSEC2USEC */
#define NSEC2USEC(nsec) div_const(nsec, (uint32_t)NSEC_PER_USEC)
#define NSEC2USEC(nsec) div_const(nsec, NSEC_PER_USEC)
/* NSEC2MSEC */
#define NSEC2MSEC(nsec) div_const(nsec, (uint32_t)NSEC_PER_MSEC)
#define NSEC2MSEC(nsec) div_const(nsec, NSEC_PER_MSEC)
#if defined(CONFIG_DEBUG_SCHED) && !defined(CONFIG_SCHED_TICKLESS)
/* Initial system timer ticks value close to maximum 32-bit value, to test
@ -232,7 +232,7 @@
*/
# define INITIAL_SYSTEM_TIMER_TICKS \
((uint64_t)(UINT32_MAX - (TICK_PER_SEC * 5)))
(UINT32_MAX - (TICK_PER_SEC * 5))
#else
# define INITIAL_SYSTEM_TIMER_TICKS 0
#endif
@ -301,13 +301,6 @@ struct cpuload_s
};
#endif
/* This non-standard type used to hold relative clock ticks that may take
* negative values. Because of its non-portable nature the type sclock_t
* should be used only within the OS proper and not by portable applications.
*/
typedef int64_t sclock_t;
/****************************************************************************
* Public Data
****************************************************************************/
@ -327,47 +320,47 @@ extern "C"
#define clock_ticks2time(ts, tick) \
do \
{ \
clock_t _tick = tick; \
(ts)->tv_sec = (time_t)div_const(_tick, (uint32_t)TICK_PER_SEC); \
_tick -= (clock_t)((ts)->tv_sec * TICK_PER_SEC); \
(ts)->tv_nsec = (long)_tick * NSEC_PER_TICK; \
clock_t _tick = (tick); \
(ts)->tv_sec = div_const(_tick, TICK_PER_SEC); \
_tick -= (ts)->tv_sec * TICK_PER_SEC; \
(ts)->tv_nsec = _tick * NSEC_PER_TICK; \
} \
while (0)
#define clock_time2ticks(ts) \
((clock_t)((ts)->tv_sec * TICK_PER_SEC) + \
(clock_t)div_const_roundup((uint64_t)(ts)->tv_nsec, (uint32_t)NSEC_PER_TICK))
((ts)->tv_sec * TICK_PER_SEC + \
div_const_roundup((ts)->tv_nsec, NSEC_PER_TICK))
#define clock_time2ticks_floor(ts) \
((clock_t)(ts)->tv_sec * TICK_PER_SEC + \
div_const((uint32_t)(ts)->tv_nsec, (uint32_t)NSEC_PER_TICK))
((ts)->tv_sec * TICK_PER_SEC + \
div_const((ts)->tv_nsec, NSEC_PER_TICK))
#define clock_usec2time(ts, usec) \
do \
{ \
uint64_t _usec = (usec); \
(ts)->tv_sec = (time_t)div_const(_usec, (uint32_t)USEC_PER_SEC); \
_usec -= (uint64_t)(ts)->tv_sec * USEC_PER_SEC; \
(ts)->tv_nsec = (long)_usec * NSEC_PER_USEC; \
int64_t _usec = (usec); \
(ts)->tv_sec = div_const(_usec, USEC_PER_SEC); \
_usec -= (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 + \
div_const((uint32_t)(ts)->tv_nsec, (uint32_t)NSEC_PER_USEC))
((ts)->tv_sec * USEC_PER_SEC + \
div_const((ts)->tv_nsec, NSEC_PER_USEC))
#define clock_nsec2time(ts, nsec) \
do \
{ \
uint64_t _nsec = (nsec); \
(ts)->tv_sec = (time_t)div_const(_nsec, (uint32_t)NSEC_PER_SEC); \
_nsec -= (uint64_t)(ts)->tv_sec * NSEC_PER_SEC; \
(ts)->tv_nsec = (long)_nsec; \
int64_t _nsec = (nsec); \
(ts)->tv_sec = div_const(_nsec, NSEC_PER_SEC); \
_nsec -= (ts)->tv_sec * NSEC_PER_SEC; \
(ts)->tv_nsec = _nsec; \
} \
while (0)
#define clock_time2nsec(ts) \
((uint64_t)(ts)->tv_sec * NSEC_PER_SEC + (uint64_t)(ts)->tv_nsec)
((ts)->tv_sec * NSEC_PER_SEC + (ts)->tv_nsec)
/* Calculate delay+1, forcing the delay into a range that we can handle.
*
@ -389,7 +382,7 @@ extern "C"
* current_tick + 1, which is not enough for at least 1 tick.
*/
#define clock_delay2abstick(delay) (clock_systime_ticks() + (delay) + 1u)
#define clock_delay2abstick(delay) (clock_systime_ticks() + (delay) + 1)
/****************************************************************************
* Name: clock_timespec_add
@ -447,7 +440,7 @@ extern "C"
_nsec += NSEC_PER_SEC; \
_sec--; \
} \
if ((sclock_t)_sec < 0) \
if (_sec < 0) \
{ \
_sec = 0; \
_nsec = 0; \
@ -540,7 +533,7 @@ int clock_realtime2absticks(FAR const struct timespec *reltime,
* false - Otherwise.
*
* Assumptions:
* The type of delay value should be sclock_t.
* The type of delay value should be clock_t.
*
****************************************************************************/
@ -554,16 +547,16 @@ int clock_realtime2absticks(FAR const struct timespec *reltime,
* it is considered not expired.
*
* For bit-63 as the sign bit, we can simplify this to:
* (sclock_t)(tick2 - tick1) >= 0.
* (clock_t)(tick2 - tick1) >= 0.
*
* However, this function requires an assumption to work correctly:
* Assumes the timer delay time does not exceed SCLOCK_MAX (2^63 - 1).
* Assumes the timer delay time does not exceed CLOCK_MAX (2^63 - 1).
*
* The range of the delay data type sclock_t being
* [- (SCLOCK_MAX + 1), SCLOCK_MAX] ensures this assumption holds.
* The range of the delay data type clock_t being
* [- (CLOCK_MAX + 1), CLOCK_MAX] ensures this assumption holds.
*/
#define clock_compare(tick1, tick2) ((sclock_t)((tick2) - (tick1)) >= 0)
#define clock_compare(tick1, tick2) ((clock_t)((tick2) - (tick1)) >= 0)
/****************************************************************************
* Name: clock_isleapyear

View file

@ -136,7 +136,7 @@ typedef int nuttx_fsid_t[2];
/* These must match the definition in include/time.h */
typedef uint64_t nuttx_time_t;
typedef int64_t nuttx_time_t;
struct nuttx_timespec
{

View file

@ -634,7 +634,7 @@ int file_mq_timedsend(FAR struct file *mq, FAR const char *msg,
****************************************************************************/
int file_mq_ticksend(FAR struct file *mq, FAR const char *msg,
size_t msglen, unsigned int prio, sclock_t ticks);
size_t msglen, unsigned int prio, clock_t ticks);
/****************************************************************************
* Name: file_mq_receive
@ -740,7 +740,7 @@ ssize_t file_mq_timedreceive(FAR struct file *mq, FAR char *msg,
ssize_t file_mq_tickreceive(FAR struct file *mq, FAR char *msg,
size_t msglen, FAR unsigned int *prio,
sclock_t ticks);
clock_t ticks);
/****************************************************************************
* Name: file_mq_setattr

View file

@ -128,7 +128,7 @@ clock_t clkcnt_max_tick(clkcnt_t max_count, uint32_t freq)
clkcnt_t cnt = max_count / freq * TICK_PER_SEC +
max_count % freq * TICK_PER_SEC / freq;
cnt = cnt <= CLOCK_MAX ? cnt : CLOCK_MAX;
return (clock_t)cnt;
return cnt;
}
/****************************************************************************
@ -427,7 +427,7 @@ clock_t clkcnt_delta_cnt2tick(clkcnt_t delta, uint32_t freq)
DEBUGASSERT(tick <= CLOCK_MAX);
return (clock_t)tick;
return tick;
}
/****************************************************************************

View file

@ -188,7 +188,7 @@ int wd_start(FAR struct wdog_s *wdog, clock_t delay,
/* Ensure delay is within the range the wdog can handle. */
if (delay <= WDOG_MAX_DELAY)
if (delay >= 0 && delay <= WDOG_MAX_DELAY)
{
ret = wd_start_abstick(wdog, clock_delay2abstick(delay), wdentry, arg);
}
@ -331,7 +331,7 @@ int wd_start_next(FAR struct wdog_s *wdog, clock_t delay,
{
/* Ensure delay is within the range the wdog can handle. */
if (delay > WDOG_MAX_DELAY)
if (delay < 0 || delay > WDOG_MAX_DELAY)
{
return -EINVAL;
}
@ -374,7 +374,7 @@ int wd_cancel(FAR struct wdog_s *wdog);
*
****************************************************************************/
sclock_t wd_gettime(FAR struct wdog_s *wdog);
clock_t wd_gettime(FAR struct wdog_s *wdog);
#undef EXTERN
#ifdef __cplusplus

View file

@ -547,7 +547,7 @@ int work_cancel_sync_wq(FAR struct kwork_wqueue_s *wqueue,
*
****************************************************************************/
#define work_timeleft(work) ((sclock_t)((work)->qtime - clock()))
#define work_timeleft(work) ((work)->qtime - clock())
/****************************************************************************
* Name: lpwork_boostpriority

View file

@ -247,12 +247,13 @@ typedef uint16_t sa_family_t;
/* Used for system times in clock ticks. This type is the natural width of
* the system timer.
*
* NOTE: The signed-ness of clock_t is not specified at OpenGroup.org. An
* unsigned type is used to support the full range of the internal clock.
* NOTE: The signed-ness of clock_t is not specified at OpenGroup.org, but
* a signed type is used to align with other OSes (Linux, BSD, etc.) and
* to allow expressing negative tick differences directly.
*/
typedef uint64_t clock_t;
typedef uint64_t time_t; /* Holds time in seconds */
typedef int64_t clock_t;
typedef int64_t time_t; /* Holds time in seconds */
typedef int clockid_t; /* Identifies one time base source */
typedef FAR void *timer_t; /* Represents one POSIX timer */

View file

@ -145,7 +145,7 @@ void dns_save_answer(FAR const char *hostname,
/* Get the current time */
clock_gettime(CLOCK_MONOTONIC, &now);
entry->ctime = (time_t)now.tv_sec;
entry->ctime = now.tv_sec;
#endif
strlcpy(entry->name, hostname, CONFIG_NETDB_DNSCLIENT_NAMESIZE);
@ -212,7 +212,7 @@ int dns_find_answer(FAR const char *hostname, FAR union dns_addr_u *addr,
FAR struct dns_cache_s *entry;
#if CONFIG_NETDB_DNSCLIENT_LIFESEC > 0
struct timespec now;
uint32_t elapsed;
time_t elapsed;
int ret;
#endif
int next;
@ -243,12 +243,9 @@ int dns_find_answer(FAR const char *hostname, FAR union dns_addr_u *addr,
}
#if CONFIG_NETDB_DNSCLIENT_LIFESEC > 0
/* Check if this entry has expired
* REVISIT: Does not this calculation assume that the sizeof(time_t)
* is equal to the sizeof(uint32_t)?
*/
/* Check if this entry has expired */
elapsed = (uint32_t)now.tv_sec - (uint32_t)entry->ctime;
elapsed = now.tv_sec - entry->ctime;
if (ret >= 0 &&
(elapsed > CONFIG_NETDB_DNSCLIENT_LIFESEC || elapsed > entry->ttl))
{

View file

@ -168,7 +168,7 @@ time_t clock_calendar2utc(int year, int month, int day)
/* Add in the days up to the beginning of this month. */
days += (time_t)clock_daysbeforemonth(month, clock_isleapyear(year));
days += clock_daysbeforemonth(month, clock_isleapyear(year));
/* Add in the days since the beginning of this month (days are 1-based). */

View file

@ -80,5 +80,5 @@ time_t time(time_t *tloc)
return ts.tv_sec;
}
return (time_t)ERROR;
return ERROR;
}

View file

@ -46,7 +46,7 @@
static clock_t iob_allocwait_gettimeout(clock_t start, unsigned int timeout)
{
sclock_t tick;
clock_t tick;
tick = clock_systime_ticks() - start;
if (tick >= MSEC2TICK(timeout))

View file

@ -99,16 +99,16 @@ void icmpv4_add_pmtu_entry(in_addr_t destipaddr, int mtu)
for (i = 0; i < CONFIG_NET_ICMP_PMTU_ENTRIES; i++)
{
if ((g_icmp_pmtu_entry[i].pmtu == 0) ||
(sclock_t)(now - g_icmp_pmtu_entry[i].time) >=
if (g_icmp_pmtu_entry[i].pmtu == 0 ||
now - g_icmp_pmtu_entry[i].time >=
SEC2TICK(CONFIG_NET_ICMP_PMTU_TIMEOUT * 60))
{
j = i;
break;
}
if ((sclock_t)(g_icmp_pmtu_entry[i].time -
g_icmp_pmtu_entry[j].time) < 0)
if (g_icmp_pmtu_entry[i].time -
g_icmp_pmtu_entry[j].time < 0)
{
j = i;
}

View file

@ -99,15 +99,15 @@ void icmpv6_add_pmtu_entry(net_ipv6addr_t destipaddr, int mtu)
for (i = 0; i < CONFIG_NET_ICMPv6_PMTU_ENTRIES; i++)
{
if (g_icmpv6_pmtu_entry[i].pmtu == 0 ||
(sclock_t)(now - g_icmpv6_pmtu_entry[i].time) >=
now - g_icmpv6_pmtu_entry[i].time >=
SEC2TICK(CONFIG_NET_ICMPv6_PMTU_TIMEOUT * 60))
{
j = i;
break;
}
if ((sclock_t)(g_icmpv6_pmtu_entry[i].time -
g_icmpv6_pmtu_entry[j].time) < 0)
if (g_icmpv6_pmtu_entry[i].time -
g_icmpv6_pmtu_entry[j].time < 0)
{
j = i;
}

View file

@ -192,7 +192,7 @@ static void ip_fragin_timerout_expiry(wdparm_t arg)
static void ip_fragin_timerwork(FAR void *arg)
{
clock_t curtick = clock_systime_ticks();
sclock_t interval = 0;
clock_t interval = 0;
FAR sq_entry_t *entry;
FAR sq_entry_t *entrynext;
FAR struct ip_fragsnode_s *node;

View file

@ -88,46 +88,10 @@ static inline void mld_check_v1compat(FAR struct net_driver_s *dev,
* running, this will reset the timer.
*/
mld_start_v1timer(dev,
MSEC2TICK(MLD_V1PRESENT_MSEC((clock_t)MLD_QUERY_MSEC)));
mld_start_v1timer(dev, MSEC2TICK(MLD_V1PRESENT_MSEC(MLD_QUERY_MSEC)));
}
}
/****************************************************************************
* Name: mld_mrc2mrd
*
* Description:
* Convert the MLD Maximum Response Code (MRC) to the Maximum Response
* Delay (MRD) in units of system clock ticks.
*
****************************************************************************/
#if 0 /* Not used */
static clock_t mld_mrc2mrd(uint16_t mrc)
{
uint32_t mrd; /* Units of milliseconds */
/* If bit 15 is not set (i.e., mrc < 32768),
* then no conversion is required.
*/
if (mrc < 32768)
{
mrd = mrc;
}
else
{
/* Conversion required */
mrd = MLD_MRD_VALUE(mrc);
}
/* Return the MRD in units of clock ticks */
return MSEC2TICK((clock_t)mrd);
}
#endif
/****************************************************************************
* Name: mld_cmpaddr
*

View file

@ -278,7 +278,7 @@ struct tcp_conn_s
#endif
uint16_t flags; /* Flags of TCP-specific options */
#ifdef CONFIG_NET_SOLINGER
sclock_t ltimeout; /* Linger timeout expiration */
clock_t ltimeout; /* Linger timeout expiration */
#endif
#ifdef CONFIG_NETDEV_RSS
int rcvcpu; /* Current cpu id */

View file

@ -233,7 +233,7 @@ static void tcp_xmit_probe(FAR struct net_driver_s *dev,
void tcp_update_timer(FAR struct tcp_conn_s *conn)
{
sclock_t timeout = tcp_get_timeout(conn);
clock_t timeout = tcp_get_timeout(conn);
if (timeout > 0)
{
@ -242,7 +242,7 @@ void tcp_update_timer(FAR struct tcp_conn_s *conn)
if (conn->ltimeout != 0)
{
sclock_t ticks = conn->ltimeout - clock_systime_ticks();
clock_t ticks = conn->ltimeout - clock_systime_ticks();
if (ticks <= 0)
{
@ -448,7 +448,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
/* Send reset immediately if linger timeout */
if (conn->ltimeout != 0 &&
((sclock_t)(conn->ltimeout - clock_systime_ticks()) <= 0))
conn->ltimeout - clock_systime_ticks() <= 0)
{
conn->tcpstateflags = TCP_CLOSED;
ninfo("TCP state: TCP_CLOSED\n");

View file

@ -47,7 +47,7 @@
/* microseconds since midnight, January 1st, 0 AD nominal Gregorian. */
#define SNOOP_EPOCH_USEC(tv) (((tv).tv_sec - 0x386d4380ll) * 1000000ll \
#define SNOOP_EPOCH_USEC(tv) (((tv).tv_sec - 0x386d4380) * 1000000 \
+ (tv).tv_usec + 0x00e03ab44a676000ll)
/****************************************************************************

View file

@ -54,13 +54,11 @@
* None
*
* Returned Value:
* The system time in units of clock ticks is returned. If the processor
* time used is not available or its value cannot be represented, the
* function will return the value (clock_t)-1.
* The system time in units of clock ticks is returned.
*
****************************************************************************/
clock_t clock(void)
{
return (clock_t)clock_systime_ticks();
return clock_systime_ticks();
}

View file

@ -137,7 +137,7 @@ int clock_basetime(FAR struct timespec *tp)
/* Set the base time as seconds into this julian day. */
tp->tv_sec = jdn * (time_t)SEC_PER_DAY;
tp->tv_sec = jdn * SEC_PER_DAY;
tp->tv_nsec = 0;
return OK;
}

View file

@ -127,7 +127,7 @@ static void nxmq_rcvtimeout(wdparm_t arg)
int nxmq_wait_receive(FAR struct mqueue_inode_s *msgq,
FAR struct mqueue_msg_s **rcvmsg,
FAR const struct timespec *abstime,
sclock_t ticks)
clock_t ticks)
{
FAR struct mqueue_msg_s *newmsg;
FAR struct tcb_s *rtcb = this_task();

View file

@ -138,7 +138,7 @@ static
ssize_t file_mq_timedreceive_internal(FAR struct file *mq, FAR char *msg,
size_t msglen, FAR unsigned int *prio,
FAR const struct timespec *abstime,
sclock_t ticks)
clock_t ticks)
{
FAR struct mqueue_inode_s *msgq;
FAR struct mqueue_msg_s *mqmsg;
@ -325,7 +325,7 @@ ssize_t file_mq_timedreceive(FAR struct file *mq, FAR char *msg,
ssize_t file_mq_tickreceive(FAR struct file *mq, FAR char *msg,
size_t msglen, FAR unsigned int *prio,
sclock_t ticks)
clock_t ticks)
{
return file_mq_timedreceive_internal(mq, msg, msglen, prio, NULL, ticks);
}

View file

@ -275,7 +275,7 @@ static
int file_mq_timedsend_internal(FAR struct file *mq, FAR const char *msg,
size_t msglen, unsigned int prio,
FAR const struct timespec *abstime,
sclock_t ticks)
clock_t ticks)
{
FAR struct mqueue_inode_s *msgq;
FAR struct mqueue_msg_s *mqmsg;
@ -466,7 +466,7 @@ int file_mq_timedsend(FAR struct file *mq, FAR const char *msg,
****************************************************************************/
int file_mq_ticksend(FAR struct file *mq, FAR const char *msg,
size_t msglen, unsigned int prio, sclock_t ticks)
size_t msglen, unsigned int prio, clock_t ticks)
{
return file_mq_timedsend_internal(mq, msg, msglen, prio, NULL, ticks);
}

View file

@ -126,7 +126,7 @@ static void nxmq_sndtimeout(wdparm_t arg)
int nxmq_wait_send(FAR struct mqueue_inode_s *msgq,
FAR const struct timespec *abstime,
sclock_t ticks)
clock_t ticks)
{
FAR struct tcb_s *rtcb = this_task();

View file

@ -128,14 +128,14 @@ void nxmq_wait_irq(FAR struct tcb_s *wtcb, int errcode);
int nxmq_wait_receive(FAR struct mqueue_inode_s *msgq,
FAR struct mqueue_msg_s **rcvmsg,
FAR const struct timespec *abstime,
sclock_t ticks);
clock_t ticks);
void nxmq_notify_receive(FAR struct mqueue_inode_s *msgq);
/* mq_sndinternal.c *********************************************************/
int nxmq_wait_send(FAR struct mqueue_inode_s *msgq,
FAR const struct timespec *abstime,
sclock_t ticks);
clock_t ticks);
void nxmq_notify_send(FAR struct mqueue_inode_s *msgq);
/* mq_recover.c *************************************************************/

View file

@ -328,8 +328,8 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
if (policy == SCHED_SPORADIC)
{
FAR struct sporadic_s *sporadic;
sclock_t repl_ticks;
sclock_t budget_ticks;
clock_t repl_ticks;
clock_t budget_ticks;
/* Convert timespec values to system clock ticks */

View file

@ -34,7 +34,7 @@
* Pre-processor Definitions
****************************************************************************/
#define PROFTICK NSEC2TICK((clock_t)(NSEC_PER_SEC / CONFIG_SCHED_PROFILE_TICKSPERSEC))
#define PROFTICK NSEC2TICK(NSEC_PER_SEC / CONFIG_SCHED_PROFILE_TICKSPERSEC)
/****************************************************************************
* Private Types

View file

@ -55,8 +55,8 @@ int set_sporadic_param(FAR const struct sched_param *param,
if ((rtcb->flags & TCB_FLAG_POLICY_MASK) == TCB_FLAG_SCHED_SPORADIC)
{
FAR struct sporadic_s *sporadic;
sclock_t repl_ticks;
sclock_t budget_ticks;
clock_t repl_ticks;
clock_t budget_ticks;
if (param->sched_ss_max_repl >= 1 &&
param->sched_ss_max_repl <= CONFIG_SCHED_SPORADIC_MAXREPL)

View file

@ -49,8 +49,8 @@ int process_sporadic(FAR struct tcb_s *tcb,
FAR const struct sched_param *param)
{
FAR struct sporadic_s *sporadic;
sclock_t repl_ticks;
sclock_t budget_ticks;
clock_t repl_ticks;
clock_t budget_ticks;
int ret = -EINVAL;
if (param->sched_ss_max_repl >= 1 &&

View file

@ -73,7 +73,7 @@
int timer_gettime(timer_t timerid, FAR struct itimerspec *value)
{
FAR struct posix_timer_s *timer = timer_gethandle(timerid);
sclock_t ticks;
clock_t ticks;
int ret = OK;
if (!timer || !value)

View file

@ -52,12 +52,12 @@
*
****************************************************************************/
sclock_t wd_gettime(FAR struct wdog_s *wdog)
clock_t wd_gettime(FAR struct wdog_s *wdog)
{
irqstate_t flags;
clock_t expired;
bool is_active;
sclock_t delay = 0;
clock_t delay = 0;
if (wdog != NULL && WDOG_ISACTIVE(wdog))
{
@ -68,7 +68,7 @@ sclock_t wd_gettime(FAR struct wdog_s *wdog)
if (is_active)
{
delay = (sclock_t)(expired - clock_systime_ticks());
delay = expired - clock_systime_ticks();
delay = delay >= 0 ? delay : 0;
}
}

View file

@ -368,7 +368,7 @@ uint64_t wd_timer(const hrtimer_t *timer, uint64_t expired)
clock_t tick = div_const(expired, NSEC_PER_TICK);
clock_t delay = wd_expiration(tick) - tick;
uint64_t nsec = TICK2NSEC((uint64_t)delay);
uint64_t nsec = TICK2NSEC(delay);
return nsec <= HRTIMER_MAX_DELAY ? nsec : HRTIMER_MAX_DELAY;
}
#endif

View file

@ -127,11 +127,11 @@ uint64_t wd_timer(const hrtimer_t *timer, uint64_t expired);
#ifdef CONFIG_HRTIMER
static inline_function void wd_timer_start(clock_t tick, bool in_expiration)
{
DEBUGASSERT((uint64_t)tick <= UINT64_MAX / NSEC_PER_TICK);
DEBUGASSERT(tick <= INT64_MAX / NSEC_PER_TICK);
if (!in_expiration)
{
hrtimer_start(&g_wdtimer, wd_timer,
TICK2NSEC((uint64_t)tick), HRTIMER_MODE_ABS);
TICK2NSEC(tick), HRTIMER_MODE_ABS);
}
}
@ -214,7 +214,7 @@ static inline_function clock_t wd_get_next_expire(clock_t curr)
}
leave_critical_section(flags);
return (sclock_t)(next - curr) <= 0 ? 0u : next;
return next - curr <= 0 ? 0 : next;
}
#undef EXTERN