!nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats

Now that time_t is unconditionally 64-bit (signed int64_t) and the
struct timespec fields tv_sec / tv_nsec are wide enough on their own,
the explicit (uint64_t)/(int64_t)/(int) casts that used to guard the
multiplications and subtractions in *_us / *_ms / *_ns helpers are no
longer needed.  Drop them to keep the timekeeping math readable and
consistent with the previous sclock_t/time_t cleanup.

In the same spirit, this commit also:

* Normalises the printf-style format specifiers and casts used to
  print tv_sec / tv_nsec / tv_usec values across arch/, drivers/,
  fs/, sched/ and libs/.  The prior code was a mix of
  "%d"/"%u"/"%ld"/"%lu"/"%lld"/PRIu32/PRIu64 with matching
  (int)/(unsigned long)/(long long)/PRIu* casts; some formats
  truncated time_t on 32-bit hosts, others mismatched signedness or
  width.  Replace all such cases with the portable POSIX-recommended
  forms:

    - tv_sec  (time_t,       signed, impl-defined width) -> %jd  + (intmax_t)
    - tv_nsec (long,         signed)                     -> %ld  (no cast)
    - tv_usec (suseconds_t / long)                       -> %ld  (no cast)

  Add #include <stdint.h> where required.

* Drops a few stale `(FAR const time_t *)&ts.tv_sec` casts and
  related `(FAR struct tm *)` / `(const time_t *)` casts in
  gmtime_r() / localtime_r() / gmtime() callers; ts.tv_sec is plain
  time_t now and the casts only obscured the type.

* Fixes one overflow in fs/procfs/fs_procfscritmon.c where
  all_time.tv_sec * 1000000 could overflow on 32-bit time_t before
  being multiplied again; cast to uint64_t at the start.

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2026-05-17 14:30:05 +08:00 committed by Xiang Xiao
parent c47b1e2c5b
commit 9ff99c6d0f
101 changed files with 323 additions and 325 deletions

View file

@ -75,7 +75,7 @@
/* convert seconds to 64bit counter value running at 32kHz */
#define SEC_TO_CNT(sec) ((uint64_t)(((uint64_t)(sec)) << 15))
#define SEC_TO_CNT(sec) (((uint64_t)(sec)) << 15)
/* convert nano-seconds to 32kHz counter less than 1 second */
@ -157,7 +157,7 @@ static void rtc_dumptime(const struct timespec *tp, const char *msg)
gmtime_r(&tp->tv_sec, &tm);
rtcinfo("%s:\n", msg);
rtcinfo("RTC %u.%09u\n", tp->tv_sec, tp->tv_nsec);
rtcinfo("RTC %jd.%09ld\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
rtcinfo("%4d/%02d/%02d %02d:%02d:%02d\n",
tm.tm_year, tm.tm_mon, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);

View file

@ -336,7 +336,7 @@ static int cxd56_getstatus(struct timer_lowerhalf_s *lower,
/* Get the time remaining until the timer expires (in microseconds). */
remaining = (uint64_t)getreg32(priv->base + CXD56_TIMER_VALUE);
remaining = getreg32(priv->base + CXD56_TIMER_VALUE);
status->timeleft =
(uint32_t)(remaining * 1000000ULL * TIMER_DIVIDER / priv->clkticks);

View file

@ -391,7 +391,7 @@ static int cxd56_getstatus(struct watchdog_lowerhalf_s *lower,
/* Get the time remaining until the watchdog expires (in milliseconds) */
remain = (uint64_t)cxd56_getreg(CXD56_WDT_WDOGVALUE);
remain = cxd56_getreg(CXD56_WDT_WDOGVALUE);
status->timeleft = (uint32_t)(remain * 1000 / cxd56_get_cpu_baseclk());
if (cxd56_getreg(CXD56_WDT_WDOGRIS) != WDOGRIS_RAWINT)
{

View file

@ -431,7 +431,7 @@ int up_rtc_gettime(struct timespec *tp)
tp->tv_nsec = (val % CONFIG_RTC_FREQUENCY) *
(NSEC_PER_SEC / CONFIG_RTC_FREQUENCY);
rtcinfo("Get RTC %u.%09u\n", tp->tv_sec, tp->tv_nsec);
rtcinfo("Get RTC %jd.%09ld\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
return OK;
}
@ -481,8 +481,8 @@ int up_rtc_settime(const struct timespec *tp)
cnt_carry = val / __CNT_TOP;
cnt = val % __CNT_TOP;
rtcinfo("Set RTC %u.%09u carry %u zero %u reg %u\n",
tp->tv_sec, tp->tv_nsec, cnt_carry, cnt, cnt_reg);
rtcinfo("Set RTC %jd.%09ld carry %u zero %u reg %u\n",
(intmax_t)tp->tv_sec, tp->tv_nsec, cnt_carry, cnt, cnt_reg);
putreg32(cnt_carry, __CNT_CARRY_REG);
putreg32(cnt , __CNT_ZERO_REG);

View file

@ -515,8 +515,7 @@ static int kinetis_rdalarm(struct rtc_lowerhalf_s *lower,
flags = enter_critical_section();
ret = kinetis_rtc_rdalarm(&ts);
localtime_r((const time_t *)&ts.tv_sec,
(struct tm *)alarminfo->time);
localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time);
leave_critical_section(flags);
}

View file

@ -727,6 +727,6 @@ int up_rtc_gettime(struct timespec *tp)
tp->tv_sec = secs;
tp->tv_nsec = nsecs;
tmrinfo("Returning tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec);
tmrinfo("Returning tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
return OK;
}

View file

@ -97,7 +97,7 @@ void up_timer_initialize(void)
* of the timer0 module clock (in the AHB0APB1_BASE domain (2)).
*/
freq = (uint64_t)lpc31_clkfreq(CLKID_TIMER0PCLK, DOMAINID_AHB0APB1);
freq = lpc31_clkfreq(CLKID_TIMER0PCLK, DOMAINID_AHB0APB1);
/* If the clock is >1MHz, use pre-dividers */

View file

@ -362,7 +362,7 @@ static int nrf52_settimeout(struct watchdog_lowerhalf_s *lower,
nrf52_wdt_behaviour_set(priv->mode);
nrf52_wdt_reload_value_set(((uint64_t) timeout * 32768) / 1000);
nrf52_wdt_reload_value_set(((uint64_t)timeout * 32768) / 1000);
up_enable_irq(NRF52_IRQ_WDT);

View file

@ -118,7 +118,7 @@ bool rp2040_clock_configure(int clk_index,
* (left shift by 8)
*/
div = (uint32_t) (((uint64_t) src_freq << 8) / freq);
div = (uint32_t)(((uint64_t)src_freq << 8) / freq);
/* If increasing divisor, set divisor before source. Otherwise set source
* before divisor. This avoids a momentary overspeed when e.g. switching

View file

@ -124,7 +124,7 @@ bool rp23xx_clock_configure(int clk_index,
* (left shift by 16)
*/
div = (uint32_t) (((uint64_t) src_freq << 16) / freq);
div = (uint32_t)(((uint64_t)src_freq << 16) / freq);
/* If increasing divisor, set divisor before source. Otherwise set source
* before divisor. This avoids a momentary overspeed when e.g. switching

View file

@ -518,7 +518,7 @@ static unsigned int __div64_32(uint64_t *n, unsigned int base)
if (high >= base)
{
high /= base;
res = (uint64_t) high << 32;
res = (uint64_t)high << 32;
rem -= (uint64_t)(high * base) << 32;
}

View file

@ -157,7 +157,7 @@ static int s32k3xx_wkpuinterrupt(int irq, void *context, void *arg)
wisr_64 = getreg32(S32K3XX_WKPU_WISR_64);
irer_64 = getreg32(S32K3XX_WKPU_IRER_64);
eif = (wisr & irer) | (((uint64_t) (wisr_64 & irer_64)) << 32);
eif = (wisr & irer) | (((uint64_t)(wisr_64 & irer_64)) << 32);
/* Examine each WKPU source */

View file

@ -276,8 +276,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -233,7 +233,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec)
{
DEBUGASSERT(oneshot && usec);
*usec = (0xffffull * USEC_PER_SEC) /
(uint64_t)sam_tc_divfreq(oneshot->tch);
sam_tc_divfreq(oneshot->tch);
return OK;
}
@ -266,9 +266,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot,
uint64_t regval;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
/* Was the oneshot already running? */
@ -500,8 +499,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -277,8 +277,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -243,7 +243,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec)
{
DEBUGASSERT(oneshot != NULL && usec != NULL);
*usec = (0xffffull * USEC_PER_SEC) /
(uint64_t)sam_tc_divfreq(oneshot->tch);
sam_tc_divfreq(oneshot->tch);
return OK;
}
@ -276,9 +276,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot,
uint64_t regval;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
/* Was the oneshot already running? */
@ -511,8 +510,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -265,7 +265,7 @@ void up_timer_initialize(void)
/* Convert this to configured clock ticks for use by the OS timer logic */
max_delay /= CONFIG_USEC_PER_TICK;
if (max_delay > (uint64_t)UINT32_MAX)
if (max_delay > UINT32_MAX)
{
g_oneshot_maxticks = UINT32_MAX;
}

View file

@ -213,8 +213,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -178,7 +178,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec)
{
DEBUGASSERT(oneshot != NULL && usec != NULL);
*usec = (0xffffull * USEC_PER_SEC) /
(uint64_t)sam_tc_divfreq(oneshot->tch);
sam_tc_divfreq(oneshot->tch);
return OK;
}
@ -211,8 +211,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot,
uint64_t regval;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
/* Was the oneshot already running? */
@ -445,8 +445,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -263,7 +263,7 @@ void up_timer_initialize(void)
/* Convert this to configured clock ticks for use by the OS timer logic */
max_delay /= CONFIG_USEC_PER_TICK;
if (max_delay > (uint64_t)UINT32_MAX)
if (max_delay > UINT32_MAX)
{
g_oneshot_maxticks = UINT32_MAX;
}
@ -398,8 +398,7 @@ int up_timer_cancel(struct timespec *ts)
int up_timer_start(const struct timespec *ts)
{
tmrinfo("ts=(%lu, %lu)\n", (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("ts=(%jd, %ld)\n", (intmax_t)ts->tv_sec, ts->tv_nsec);
return ONESHOT_INITIALIZED(&g_tickless.oneshot) ?
sam_oneshot_start(&g_tickless.oneshot, &g_tickless.freerun,
sam_oneshot_handler, NULL, ts) :

View file

@ -277,8 +277,8 @@ int sam_freerun_counter(struct sam_freerun_s *freerun, struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -244,7 +244,7 @@ int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec)
{
DEBUGASSERT(oneshot != NULL && usec != NULL);
*usec = (0xffffull * USEC_PER_SEC) /
(uint64_t)sam_tc_divfreq(oneshot->tch);
sam_tc_divfreq(oneshot->tch);
return OK;
}
@ -277,9 +277,8 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot,
uint64_t regval;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
/* Was the oneshot already running? */
@ -510,8 +509,8 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -34,6 +34,7 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <poll.h>
@ -177,7 +178,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op)
_info(" fileno:%d\n", (int) bbf->fileno);
_info(" dirty:%d\n", (int) bbf->dirty);
_info(" length:%d\n", (int) bbf->len);
_info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec);
_info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec,
bbf->lastwrite.tv_nsec);
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
}

View file

@ -3582,7 +3582,7 @@ static int stm32_eth_ptp_adjust(long ppb)
if (ppb != 0)
{
addend += (int64_t)addend * ppb / NSEC_PER_SEC;
addend += addend * ppb / NSEC_PER_SEC;
}
/* Check for overflows */

View file

@ -247,7 +247,7 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%ju, %lu)\n",
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
@ -257,7 +257,7 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun,
int stm32_freerun_counter(struct stm32_freerun_s *freerun, uint64_t *counter)
{
*counter = (uint64_t)STM32_TIM_GETCOUNTER(freerun->tch);
*counter = STM32_TIM_GETCOUNTER(freerun->tch);
return OK;
}

View file

@ -259,9 +259,8 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
uint64_t period;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
DEBUGASSERT(oneshot->tch);
@ -449,8 +448,8 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -832,8 +832,8 @@ int stm32_rtc_rdalarm(FAR struct alm_rdalarm_s *alminfo)
regvals.cnth = getreg16(STM32_RTC_ALRH);
regvals.cntl = getreg16(STM32_RTC_ALRL);
tp.tv_sec = regvals.cnth << 16 | regvals.cntl;
memcpy(alminfo->ar_time, (FAR struct tm *)gmtime(&tp.tv_sec),
sizeof(FAR struct tm));
memcpy(alminfo->ar_time, gmtime(&tp.tv_sec),
sizeof(struct tm));
ret = OK;
}
break;

View file

@ -686,8 +686,8 @@ int up_timer_gettime(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}
@ -872,8 +872,8 @@ int up_timer_cancel(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;
@ -911,8 +911,8 @@ int up_timer_start(const struct timespec *ts)
uint32_t count;
irqstate_t flags;
tmrinfo("ts=(%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("ts=(%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(ts);
DEBUGASSERT(g_tickless.tch);

View file

@ -417,7 +417,7 @@ static int stm32_getstatus(struct timer_lowerhalf_s *lower,
}
else
{
timeout = ((uint64_t) period * 1000000) / clock;
timeout = ((uint64_t)period * 1000000) / clock;
}
status->timeout = timeout;
@ -425,7 +425,7 @@ static int stm32_getstatus(struct timer_lowerhalf_s *lower,
/* Get the time remaining until the timer expires (in microseconds) */
counter = STM32_TIM_GETCOUNTER(priv->tim);
status->timeleft = ((uint64_t) (timeout - counter) * clock) / 1000000;
status->timeleft = ((uint64_t)(timeout - counter) * clock) / 1000000;
tmrinfo("timeout=%" PRIu32 " counter=%" PRIu32 "\n", timeout, counter);
tmrinfo("timeleft=%" PRIu32 "\n", status->timeleft);
return OK;

View file

@ -34,6 +34,7 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <poll.h>
@ -177,7 +178,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op)
_info(" fileno:%d\n", (int) bbf->fileno);
_info(" dirty:%d\n", (int) bbf->dirty);
_info(" length:%d\n", (int) bbf->len);
_info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec);
_info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec,
bbf->lastwrite.tv_nsec);
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
}

View file

@ -727,8 +727,8 @@ int up_timer_gettime(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}
@ -914,8 +914,8 @@ int up_timer_cancel(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;
@ -955,8 +955,8 @@ int up_timer_start(const struct timespec *ts)
uint32_t count;
irqstate_t flags;
tmrinfo("ts=(%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("ts=(%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(ts);
DEBUGASSERT(g_tickless.tch);

View file

@ -33,6 +33,7 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <poll.h>
@ -198,7 +199,8 @@ static void stm32_bbsram_dump(struct bbsramfh_s *bbf, char *op)
_info(" fileno:%d\n", (int) bbf->fileno);
_info(" dirty:%d\n", (int) bbf->dirty);
_info(" length:%d\n", (int) bbf->len);
_info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec);
_info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec,
bbf->lastwrite.tv_nsec);
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
}

View file

@ -263,8 +263,8 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
uint64_t period;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", handler, arg,
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", handler, arg,
(intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
DEBUGASSERT(oneshot->tch);

View file

@ -701,8 +701,8 @@ int up_timer_gettime(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}
@ -888,8 +888,8 @@ int up_timer_cancel(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;
@ -929,8 +929,8 @@ int up_timer_start(const struct timespec *ts)
uint32_t count;
irqstate_t flags;
tmrinfo("ts=(%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("ts=(%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(ts);
DEBUGASSERT(g_tickless.tch);

View file

@ -231,8 +231,8 @@ int stm32l4_freerun_counter(struct stm32l4_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%u, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -260,9 +260,8 @@ int stm32l4_oneshot_start(struct stm32l4_oneshot_s *oneshot,
uint64_t period;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
DEBUGASSERT(oneshot->tch);
@ -451,8 +450,8 @@ int stm32l4_oneshot_cancel(struct stm32l4_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -245,7 +245,7 @@ int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%ju, %lu)\n",
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
@ -256,7 +256,7 @@ int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun,
int stm32wb_freerun_counter(struct stm32wb_freerun_s *freerun,
uint64_t *counter)
{
*counter = (uint64_t)STM32WB_TIM_GETCOUNTER(freerun->tch);
*counter = STM32WB_TIM_GETCOUNTER(freerun->tch);
return OK;
}

View file

@ -260,9 +260,8 @@ int stm32wb_oneshot_start(struct stm32wb_oneshot_s *oneshot,
uint64_t period;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
DEBUGASSERT(oneshot->tch);
@ -450,8 +449,8 @@ int stm32wb_oneshot_cancel(struct stm32wb_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -552,8 +552,8 @@ int up_timer_gettime(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}
@ -738,8 +738,8 @@ int up_timer_cancel(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;
@ -777,8 +777,8 @@ int up_timer_start(const struct timespec *ts)
uint32_t count;
irqstate_t flags;
tmrinfo("ts=(%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("ts=(%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(ts);
DEBUGASSERT(g_tickless.tch);

View file

@ -375,8 +375,8 @@ int up_timer_gettime(struct timespec *ts)
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}
@ -412,8 +412,8 @@ int up_timer_start(const struct timespec *ts)
uint64_t period;
irqstate_t flags;
tmrinfo("ts=(%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("ts=(%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(ts);
/* Was an interval already running? */
@ -566,8 +566,8 @@ int up_timer_cancel(struct timespec *ts)
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);
tmrinfo("remaining count : %lu (%jd, %ld)\n", count,
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -666,7 +666,7 @@ uint64_t *arm64_fatal_handler(uint64_t *regs)
tcb->flags |= TCB_FLAG_FORCED_CANCEL;
regs[REG_ELR] = (uint64_t) _exit;
regs[REG_ELR] = (uint64_t)_exit;
regs[REG_X0] = SIGSEGV;
regs[REG_SPSR] &= ~SPSR_MODE_MASK;
regs[REG_SPSR] |= SPSR_MODE_EL1H;

View file

@ -2441,7 +2441,7 @@ static int imx9_recvsetup(struct sdio_dev_s *dev, uint8_t *buffer,
{
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0);
DEBUGASSERT(((uint64_t) buffer & 3) == 0);
DEBUGASSERT(((uint64_t)buffer & 3) == 0);
/* Reset the DPSM configuration */
@ -2492,7 +2492,7 @@ static int imx9_sendsetup(struct sdio_dev_s *dev,
{
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0);
DEBUGASSERT(((uint64_t) buffer & 3) == 0);
DEBUGASSERT(((uint64_t)buffer & 3) == 0);
/* Reset the DPSM configuration */
@ -3230,12 +3230,12 @@ static int imx9_dmarecvsetup(struct sdio_dev_s *dev,
imx9_configxfrints(priv, USDHC_DMADONE_INTS);
if (priv->unaligned_rx)
{
putreg32((uint64_t) priv->rxbuffer,
putreg32((uint64_t)priv->rxbuffer,
priv->addr + IMX9_USDHC_DSADDR_OFFSET);
}
else
{
putreg32((uint64_t) priv->buffer,
putreg32((uint64_t)priv->buffer,
priv->addr + IMX9_USDHC_DSADDR_OFFSET);
}
@ -3271,7 +3271,7 @@ static int imx9_dmasendsetup(struct sdio_dev_s *dev,
{
struct imx9_dev_s *priv = (struct imx9_dev_s *)dev;
DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0);
DEBUGASSERT(((uint64_t) buffer & 3) == 0);
DEBUGASSERT(((uint64_t)buffer & 3) == 0);
/* Begin sampling register values */
@ -3297,7 +3297,7 @@ static int imx9_dmasendsetup(struct sdio_dev_s *dev,
/* Configure the TX DMA */
putreg32((uint64_t) buffer, priv->addr + IMX9_USDHC_DSADDR_OFFSET);
putreg32((uint64_t)buffer, priv->addr + IMX9_USDHC_DSADDR_OFFSET);
/* Sample the register state */

View file

@ -260,8 +260,8 @@ int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%u, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}
@ -271,8 +271,8 @@ int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun,
int pic32mz_freerun_counter(struct pic32mz_freerun_s *freerun,
uint64_t *counter)
{
*counter = (uint64_t)PIC32MZ_TIMER_GETCOUNTER(freerun->timer) &
freerun->counter_mask;
*counter = PIC32MZ_TIMER_GETCOUNTER(freerun->timer) &
freerun->counter_mask;
return OK;
}

View file

@ -277,9 +277,8 @@ int pic32mz_oneshot_start(struct pic32mz_oneshot_s *oneshot,
uint64_t period;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
DEBUGASSERT(oneshot->timer);
@ -437,8 +436,8 @@ int pic32mz_oneshot_cancel(struct pic32mz_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -34,6 +34,7 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <poll.h>
@ -170,7 +171,8 @@ static void rx65n_sbram_dump(struct sbramfh_s *bbf, char *op)
_info(" fileno:%d\n", (int) bbf->fileno);
_info(" dirty:%d\n", (int) bbf->dirty);
_info(" length:%d\n", (int) bbf->len);
_info(" time:%ld:%ld\n", bbf->lastwrite.tv_sec, bbf->lastwrite.tv_nsec);
_info(" time:%jd:%ld\n", (intmax_t)bbf->lastwrite.tv_sec,
bbf->lastwrite.tv_nsec);
_info(" data: 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x\n",
bbf->data[0], bbf->data[1], bbf->data[2], bbf->data[3], bbf->data[4]);
}

View file

@ -203,7 +203,7 @@ void IRAM_ATTR ets_timer_arm(ets_timer *ptimer,
uint32_t time_ms,
bool repeat_flag)
{
uint64_t time_us = 1000LL * (uint64_t) time_ms;
uint64_t time_us = 1000LL * (uint64_t)time_ms;
assert(timer_initialized(ptimer));

View file

@ -630,8 +630,7 @@ static int esp_rtc_rdalarm(struct rtc_lowerhalf_s *lower,
ts.tv_nsec = ((esp_hr_timer_time_us() + g_rtc_save->offset +
cbinfo->deadline_us) % USEC_PER_SEC) * NSEC_PER_USEC;
localtime_r((const time_t *)&ts.tv_sec,
(struct tm *)alarminfo->time);
localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time);
spin_unlock_irqrestore(&priv->lock, flags);

View file

@ -131,7 +131,7 @@ uint64_t riscv_sbi_get_time(void)
}
while (hi != READ_CSR(CSR_TIMEH));
return (((uint64_t) hi) << 32) | lo;
return (((uint64_t)hi) << 32) | lo;
#endif
}

View file

@ -1399,7 +1399,7 @@ static uint32_t IRAM_ATTR btdm_lpcycles_2_hus(uint32_t cycles,
static uint32_t IRAM_ATTR btdm_hus_2_lpcycles(uint32_t us)
{
uint64_t cycles;
cycles = ((uint64_t)(us) << g_btdm_lpcycle_us_frac) / g_btdm_lpcycle_us;
cycles = ((uint64_t)us << g_btdm_lpcycle_us_frac) / g_btdm_lpcycle_us;
return (uint32_t)cycles;
}

View file

@ -301,8 +301,8 @@ int esp32c3_freerun_counter(struct esp32c3_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo(" usec=%" PRIu64 " ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo(" usec=%" PRIu64 " ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -28,6 +28,7 @@
#include <sys/types.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
@ -258,9 +259,8 @@ int esp32c3_oneshot_start(struct esp32c3_oneshot_s *oneshot,
uint64_t timeout_us;
int ret = OK;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot != NULL);
DEBUGASSERT(handler != NULL);
DEBUGASSERT(ts != NULL);

View file

@ -735,7 +735,7 @@ static uint32_t IRAM_ATTR esp32c3_rtc_clk_cal_internal(
expected_freq = RTC_SLOW_CLK_FREQ_90K;
}
us_time_estimate = (uint32_t) (((uint64_t) slowclk_cycles) *
us_time_estimate = (uint32_t)(((uint64_t)slowclk_cycles) *
MHZ / expected_freq);
/* Start calibration */
@ -2509,7 +2509,7 @@ uint64_t IRAM_ATTR esp32c3_rtc_time_get(void)
modifyreg32(RTC_CNTL_TIME_UPDATE_REG, 0, RTC_CNTL_TIME_UPDATE);
rtc_time = getreg32(RTC_CNTL_TIME0_REG);
rtc_time |= ((uint64_t) getreg32(RTC_CNTL_TIME1_REG)) << 32;
rtc_time |= ((uint64_t)getreg32(RTC_CNTL_TIME1_REG)) << 32;
return rtc_time;
}

View file

@ -483,8 +483,7 @@ static int rtc_lh_rdalarm(struct rtc_lowerhalf_s *lower,
flags = spin_lock_irqsave(&priv->lock);
ret = up_rtc_rdalarm(&ts, alarminfo->id);
localtime_r((const time_t *)&ts.tv_sec,
(struct tm *)alarminfo->time);
localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time);
spin_unlock_irqrestore(&priv->lock, flags);

View file

@ -47,36 +47,36 @@
* Pre-processor Definitions
****************************************************************************/
#define PUT_UINT32_BE(n,b,i) \
{ \
(b)[(i)] = (unsigned char) ((n) >> 24); \
(b)[(i) + 1] = (unsigned char) ((n) >> 16); \
(b)[(i) + 2] = (unsigned char) ((n) >> 8); \
(b)[(i) + 3] = (unsigned char) ((n)); \
#define PUT_UINT32_BE(n,b,i) \
{ \
(b)[(i)] = (unsigned char)((n) >> 24); \
(b)[(i) + 1] = (unsigned char)((n) >> 16); \
(b)[(i) + 2] = (unsigned char)((n) >> 8); \
(b)[(i) + 3] = (unsigned char)((n)); \
}
#define GET_UINT64_BE(n,b,i) \
{ \
(n) = ((uint64_t) (b)[(i)] << 56) \
| ((uint64_t) (b)[(i) + 1] << 48) \
| ((uint64_t) (b)[(i) + 2] << 40) \
| ((uint64_t) (b)[(i) + 3] << 32) \
| ((uint64_t) (b)[(i) + 4] << 24) \
| ((uint64_t) (b)[(i) + 5] << 16) \
| ((uint64_t) (b)[(i) + 6] << 8) \
| ((uint64_t) (b)[(i) + 7]); \
#define GET_UINT64_BE(n,b,i) \
{ \
(n) = ((uint64_t)(b)[(i)] << 56) \
| ((uint64_t)(b)[(i) + 1] << 48) \
| ((uint64_t)(b)[(i) + 2] << 40) \
| ((uint64_t)(b)[(i) + 3] << 32) \
| ((uint64_t)(b)[(i) + 4] << 24) \
| ((uint64_t)(b)[(i) + 5] << 16) \
| ((uint64_t)(b)[(i) + 6] << 8) \
| ((uint64_t)(b)[(i) + 7]); \
}
#define PUT_UINT64_BE(n,b,i) \
{ \
(b)[(i)] = (uint8_t) ((n) >> 56); \
(b)[(i) + 1] = (uint8_t) ((n) >> 48); \
(b)[(i) + 2] = (uint8_t) ((n) >> 40); \
(b)[(i) + 3] = (uint8_t) ((n) >> 32); \
(b)[(i) + 4] = (uint8_t) ((n) >> 24); \
(b)[(i) + 5] = (uint8_t) ((n) >> 16); \
(b)[(i) + 6] = (uint8_t) ((n) >> 8); \
(b)[(i) + 7] = (uint8_t) ((n)); \
#define PUT_UINT64_BE(n,b,i) \
{ \
(b)[(i)] = (uint8_t)((n) >> 56); \
(b)[(i) + 1] = (uint8_t)((n) >> 48); \
(b)[(i) + 2] = (uint8_t)((n) >> 40); \
(b)[(i) + 3] = (uint8_t)((n) >> 32); \
(b)[(i) + 4] = (uint8_t)((n) >> 24); \
(b)[(i) + 5] = (uint8_t)((n) >> 16); \
(b)[(i) + 6] = (uint8_t)((n) >> 8); \
(b)[(i) + 7] = (uint8_t)((n)); \
}
#define SHR(x,n) ((x) >> (n))

View file

@ -191,7 +191,7 @@ static inline uint64_t up_tmr_getcounter(void)
static inline uint64_t up_tmr_getalarmvalue(void)
{
return ((uint64_t) getreg32(SYS_TIMER_SYSTIMER_TARGET0_HI_REG) << 32) \
return ((uint64_t)getreg32(SYS_TIMER_SYSTIMER_TARGET0_HI_REG) << 32) \
| getreg32(SYS_TIMER_SYSTIMER_TARGET0_LO_REG);
}

View file

@ -384,10 +384,10 @@ static void esp32c3_tim_getcounter(struct esp32c3_tim_dev_s *dev,
/* Discard the top 12 bits */
value_32 &= LOW_20_MASK;
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(SYS_TIMER_SYSTIMER_UNIT1_VALUE_LO_REG);
*value |= (uint64_t)value_32;
*value |= value_32;
}
else
{
@ -402,10 +402,10 @@ static void esp32c3_tim_getcounter(struct esp32c3_tim_dev_s *dev,
/* Discard the top 10 bits */
value_32 &= LOW_22_MASK;
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T0LO_REG(priv->id)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
}
@ -521,10 +521,10 @@ static void esp32c3_tim_getalarmvalue(struct esp32c3_tim_dev_s *dev,
/* Get only the 20 low bits. */
value_32 &= LOW_20_MASK;
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(SYS_TIMER_SYSTIMER_TARGET2_LO_REG); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
else
{
@ -535,10 +535,10 @@ static void esp32c3_tim_getalarmvalue(struct esp32c3_tim_dev_s *dev,
/* Get only the 22 low bits. */
value_32 &= LOW_22_MASK;
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T0ALARMLO_REG(priv->id)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
}

View file

@ -2090,7 +2090,7 @@ static inline uint64_t rotl(uint64_t x, int k)
return (x << k) | (x >> (-k & 0x3f));
}
static int mpfs_ddr_rand(void)
static uint32_t mpfs_ddr_rand(void)
{
uint64_t s0 = prng_state[0];
uint64_t s1 = prng_state[1];
@ -2099,7 +2099,7 @@ static int mpfs_ddr_rand(void)
prng_state[0] = s0 ^ rotl(s1, 29);
prng_state[1] = s0 ^ (s1 << 9);
return (int)result;
return (uint32_t)result;
}
/****************************************************************************
@ -2145,7 +2145,7 @@ static void mpfs_ddr_write(struct mpfs_ddr_priv_s *priv,
break;
case PATTERN_RANDOM:
data = (uint64_t)mpfs_ddr_rand();
data = mpfs_ddr_rand();
break;
case PATTERN_CCCCCCCC:
@ -2212,7 +2212,7 @@ static void mpfs_ddr_write(struct mpfs_ddr_priv_s *priv,
break;
case PATTERN_RANDOM:
data = (uint64_t)mpfs_ddr_rand();
data = mpfs_ddr_rand();
break;
case PATTERN_CCCCCCCC:
@ -2287,7 +2287,7 @@ uint32_t mpfs_ddr_read(struct mpfs_ddr_priv_s *priv,
break;
case PATTERN_RANDOM:
data = (uint64_t)mpfs_ddr_rand();
data = mpfs_ddr_rand();
*ddr_word_ptr = data;
*ddr_32_pt_t = (uint32_t)data;
break;
@ -2366,8 +2366,8 @@ uint32_t mpfs_ddr_read(struct mpfs_ddr_priv_s *priv,
break;
case PATTERN_RANDOM:
data = (uint64_t)mpfs_ddr_rand();
mpfs_ddr_rand_addr_offset = (uint32_t)(mpfs_ddr_rand() &
data = mpfs_ddr_rand();
mpfs_ddr_rand_addr_offset = (mpfs_ddr_rand() &
0xffffc);
ddr_word_ptr = first_ddr_word_pt_t +
mpfs_ddr_rand_addr_offset;

View file

@ -124,7 +124,7 @@ bool rp23xx_clock_configure(int clk_index,
* (left shift by 16)
*/
div = (uint32_t) (((uint64_t) src_freq << 16) / freq);
div = (uint32_t)(((uint64_t)src_freq << 16) / freq);
/* If increasing divisor, set divisor before source. Otherwise set source
* before divisor. This avoids a momentary overspeed when e.g. switching

View file

@ -232,8 +232,8 @@ int bm3803_freerun_counter(struct bm3803_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%lld, %ld)\n",
usec, ts->tv_sec, ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -206,8 +206,8 @@ int bm3803_oneshot_start(struct bm3803_oneshot_s *oneshot,
uint64_t period;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n", handler, arg,
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", handler, arg,
(intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
DEBUGASSERT(oneshot->tch);
@ -393,8 +393,8 @@ int bm3803_oneshot_cancel(struct bm3803_oneshot_s *oneshot,
ts->tv_nsec = nsec;
}
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -290,9 +290,8 @@ int intel64_oneshot_start(struct intel64_oneshot_s *oneshot,
uint64_t compare = 0;
irqstate_t flags;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot && handler && ts);
DEBUGASSERT(oneshot->tch);
@ -464,8 +463,8 @@ int intel64_oneshot_cancel(struct intel64_oneshot_s *oneshot,
ts->tv_sec = sec;
ts->tv_nsec = nsec;
tmrinfo("remaining (%lu, %lu)\n",
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("remaining (%jd, %ld)\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
}
return OK;

View file

@ -629,8 +629,7 @@ static int esp_rtc_rdalarm(struct rtc_lowerhalf_s *lower,
ts.tv_nsec = ((esp_hr_timer_time_us() + g_rtc_save->offset +
cbinfo->deadline_us) % USEC_PER_SEC) * NSEC_PER_USEC;
localtime_r((const time_t *)&ts.tv_sec,
(struct tm *)alarminfo->time);
localtime_r(&ts.tv_sec, (struct tm *)alarminfo->time);
spin_unlock_irqrestore(&priv->lock, flags);

View file

@ -292,8 +292,8 @@ int esp32_freerun_counter(struct esp32_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo("usec=%llu ts=(%" PRIu32 ", %" PRIu32 ")\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo("usec=%llu ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -26,6 +26,7 @@
#include <sys/types.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
@ -249,9 +250,8 @@ int esp32_oneshot_start(struct esp32_oneshot_s *oneshot,
uint64_t timeout_us;
int ret = OK;
tmrinfo("handler=%p arg=%p, ts=(%" PRIu32 ", %" PRIu32 ")\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot != NULL);
DEBUGASSERT(handler != NULL);
DEBUGASSERT(ts != NULL);

View file

@ -154,8 +154,8 @@ 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=%" PRId64 "\n", ts->tv_sec);
tmrinfo("max nsec=%" PRId32 "\n", ts->tv_nsec);
tmrinfo("max sec=%jd\n", (intmax_t)ts->tv_sec);
tmrinfo("max nsec=%ld\n", ts->tv_nsec);
return OK;
}

View file

@ -351,10 +351,10 @@ static void esp32_tim_getcounter(struct esp32_tim_dev_s *dev,
/* Read value */
value_32 = esp32_tim_getreg(dev, TIM_HI_OFFSET); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = esp32_tim_getreg(dev, TIM_LO_OFFSET); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
/****************************************************************************
@ -420,10 +420,10 @@ static void esp32_tim_getalarmvalue(struct esp32_tim_dev_s *dev,
/* Read value */
value_32 = esp32_tim_getreg(dev, TIMG_ALARM_HI_OFFSET); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = esp32_tim_getreg(dev, TIMG_ALARM_LO_OFFSET); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
/****************************************************************************

View file

@ -296,8 +296,8 @@ int esp32s2_freerun_counter(struct esp32s2_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo(" usec=%" PRIu64 " ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo(" usec=%" PRIu64 " ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -263,9 +263,8 @@ int esp32s2_oneshot_start(struct esp32s2_oneshot_s *oneshot,
uint64_t timeout_us;
int ret = OK;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot != NULL);
DEBUGASSERT(handler != NULL);
DEBUGASSERT(ts != NULL);

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=%" PRId64 "\n", ts->tv_sec);
tmrinfo("max sec=%jd\n", (intmax_t)ts->tv_sec);
tmrinfo("max nsec=%ld\n", ts->tv_nsec);
return OK;

View file

@ -487,10 +487,10 @@ static void esp32s2_tim_getcounter(struct esp32s2_tim_dev_s *dev,
/* Read value */
value_32 = getreg32(SYSTIMER_VALUE_HI_REG); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(SYSTIMER_VALUE_LO_REG); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
else
{
@ -503,10 +503,10 @@ static void esp32s2_tim_getcounter(struct esp32s2_tim_dev_s *dev,
/* Read value */
value_32 = getreg32(TIMG_T0HI_REG(priv->gid)); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T0LO_REG(priv->gid)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
else
{
@ -517,10 +517,10 @@ static void esp32s2_tim_getcounter(struct esp32s2_tim_dev_s *dev,
/* Read value */
value_32 = getreg32(TIMG_T1HI_REG(priv->gid)); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T1LO_REG(priv->gid)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
}
}
@ -639,28 +639,28 @@ static void esp32s2_tim_getalarmvalue(struct esp32s2_tim_dev_s *dev,
if (priv->tid == SYSTIMER_COMP0)
{
value_32 = getreg32(SYSTIMER_TARGET0_HI_REG); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(SYSTIMER_TARGET0_LO_REG); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
else
{
if (priv->tid == TIMER0)
{
value_32 = getreg32(TIMG_T0ALARMHI_REG(priv->gid)); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T0ALARMLO_REG(priv->gid)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
else
{
value_32 = getreg32(TIMG_T1ALARMHI_REG(priv->gid)); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T1ALARMLO_REG(priv->gid)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
}
}

View file

@ -315,8 +315,8 @@ int esp32s3_freerun_counter(struct esp32s3_freerun_s *freerun,
ts->tv_sec = sec;
ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
tmrinfo(" usec=%" PRIu64 " ts=(%lu, %lu)\n",
usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec);
tmrinfo(" usec=%" PRIu64 " ts=(%jd, %ld)\n",
usec, (intmax_t)ts->tv_sec, ts->tv_nsec);
return OK;
}

View file

@ -262,9 +262,8 @@ int esp32s3_oneshot_start(struct esp32s3_oneshot_s *oneshot,
uint64_t timeout_us;
int ret = OK;
tmrinfo("handler=%p arg=%p, ts=(%lu, %lu)\n",
handler, arg, (unsigned long)ts->tv_sec,
(unsigned long)ts->tv_nsec);
tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
DEBUGASSERT(oneshot != NULL);
DEBUGASSERT(handler != NULL);

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=%" PRId64 "\n", ts->tv_sec);
tmrinfo("max sec=%jd\n", (intmax_t)ts->tv_sec);
tmrinfo("max nsec=%ld\n", ts->tv_nsec);
return OK;

View file

@ -148,7 +148,7 @@ static inline uint64_t tickless_getcounter(void)
}
while (lo_start != lo);
counter = ((uint64_t) hi << 32) | lo;
counter = ((uint64_t)hi << 32) | lo;
return counter;
}
@ -171,7 +171,7 @@ static inline uint64_t tickless_getalarmvalue(void)
{
uint32_t hi = getreg32(SYSTIMER_TARGET0_HI_REG);
uint32_t lo = getreg32(SYSTIMER_TARGET0_LO_REG);
uint64_t ticks = ((uint64_t) hi << 32) | lo;
uint64_t ticks = ((uint64_t)hi << 32) | lo;
return ticks;
}

View file

@ -425,10 +425,10 @@ static void tim_getcounter(struct esp32s3_tim_dev_s *dev, uint64_t *value)
/* Read value */
value_32 = getreg32(TIMG_T0HI_REG(priv->gid)); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T0LO_REG(priv->gid)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
else
{
@ -439,10 +439,10 @@ static void tim_getcounter(struct esp32s3_tim_dev_s *dev, uint64_t *value)
/* Read value */
value_32 = getreg32(TIMG_T1HI_REG(priv->gid)); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T1LO_REG(priv->gid)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
}
@ -545,18 +545,18 @@ static void tim_getalarmvalue(struct esp32s3_tim_dev_s *dev, uint64_t *value)
if (priv->tid == ESP32S3_TIM_TIMER0)
{
value_32 = getreg32(TIMG_T0ALARMHI_REG(priv->gid)); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T0ALARMLO_REG(priv->gid)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
else
{
value_32 = getreg32(TIMG_T1ALARMHI_REG(priv->gid)); /* High 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
*value <<= SHIFT_32;
value_32 = getreg32(TIMG_T1ALARMLO_REG(priv->gid)); /* Low 32 bits */
*value |= (uint64_t)value_32;
*value |= value_32;
}
}

View file

@ -433,7 +433,7 @@ void up_rngaddentropy(enum rnd_source_t kindof, FAR const uint32_t *buf,
*/
clock_systime_timespec(&ts);
tbuf[0] = ROTL_32((uint32_t)ts.tv_nsec, 17) ^ ROTL_32(ts.tv_sec, 3);
tbuf[0] = ROTL_32(ts.tv_nsec, 17) ^ ROTL_32(ts.tv_sec, 3);
tbuf[0] += ROTL_32(kindof, 27);
tbuf[0] += ROTL_32((uintptr_t)&tbuf[0], 11);

View file

@ -80,8 +80,8 @@ static void optee_rpc_cmd_get_time(FAR struct optee_msg_arg *arg)
return;
}
arg->params[0].u.value.a = (uint32_t)ts.tv_sec; /* Seconds since epoch. */
arg->params[0].u.value.b = (uint32_t)ts.tv_nsec; /* Nanoseconds. */
arg->params[0].u.value.a = ts.tv_sec; /* Seconds since epoch. */
arg->params[0].u.value.b = ts.tv_nsec; /* Nanoseconds. */
arg->ret = TEE_SUCCESS;
}

View file

@ -817,9 +817,9 @@ static int noteram_dump_header(FAR struct lib_outstream_s *s,
int cpu = 0;
#endif
ret = lib_sprintf(s, "%8s-%-3u [%d] %3" PRIu64 ".%09ld: ",
ret = lib_sprintf(s, "%8s-%-3u [%d] %3jd.%09ld: ",
note_get_taskname(pid, buf, TASK_NAME_SIZE),
get_pid(pid), cpu, ts.tv_sec, ts.tv_nsec);
get_pid(pid), cpu, (intmax_t)ts.tv_sec, ts.tv_nsec);
return ret;
}

View file

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

View file

@ -281,7 +281,7 @@ static int mpl115a_getpressure(FAR struct mpl115a_dev_s *priv)
/* These code are from Freescale AN3785 */
c12x2 = ((int32_t)priv->mpl115a_cal_c12 * tadc) >> 11;
a1 = (int32_t) (priv->mpl115a_cal_b1 + c12x2);
a1 = (int32_t)(priv->mpl115a_cal_b1 + c12x2);
a1x1 = a1 * padc;
y1 = (((int32_t)priv->mpl115a_cal_a0) << 10) + a1x1;
a2x2 = (((int32_t)priv->mpl115a_cal_b2) * tadc) >> 1;

View file

@ -491,11 +491,11 @@ static int32_t ms56xx_compensate_temp(FAR struct ms56xx_dev_s *priv,
/* dt = d1 - c5 * 256 */
dt = temp_raw - ((int32_t) c->c5 << 8);
dt = temp_raw - ((int32_t)c->c5 << 8);
/* temp = 2000 + (dt * c6) / 8388608 */
temp = 2000 + (((int64_t) (dt * c->c6)) >> 23);
temp = 2000 + (((int64_t)(dt * c->c6)) >> 23);
/* Save dt that will be used for pressure calibration */
@ -535,8 +535,8 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
switch (priv->model)
{
case MS56XX_MODEL_MS5607:
off = ((int64_t) c->c2 << 17) + ((int64_t) (c->c4 * dt) >> 6);
sens = ((int64_t) c->c1 << 16) + ((int64_t) (c->c3 * dt) >> 7);
off = ((int64_t)c->c2 << 17) + ((int64_t)(c->c4 * dt) >> 6);
sens = ((int64_t)c->c1 << 16) + ((int64_t)(c->c3 * dt) >> 7);
#if defined(CONFIG_MS56XX_SECOND_ORDER_COMPENSATE)
if (*temp < 2000)
{
@ -562,8 +562,8 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
break;
case MS56XX_MODEL_MS5611:
off = ((int64_t) c->c2 << 16) + ((int64_t) (c->c4 * dt) >> 7);
sens = ((int64_t) c->c1 << 15) + ((int64_t) (c->c3 * dt) >> 8);
off = ((int64_t)c->c2 << 16) + ((int64_t)(c->c4 * dt) >> 7);
sens = ((int64_t)c->c1 << 15) + ((int64_t)(c->c3 * dt) >> 8);
#if defined(CONFIG_MS56XX_SECOND_ORDER_COMPENSATE)
if (*temp < 2000)
{

View file

@ -440,12 +440,12 @@ static bool has_time_passed(struct timespec curr,
struct timespec start,
unsigned int secs_since_start)
{
if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0)
if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0)
{
return start.tv_nsec <= curr.tv_nsec;
}
return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0;
return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0;
}
/****************************************************************************

View file

@ -430,12 +430,12 @@ static bool has_time_passed(struct timespec curr,
struct timespec start,
unsigned int secs_since_start)
{
if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0)
if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0)
{
return start.tv_nsec <= curr.tv_nsec;
}
return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0;
return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0;
}
/****************************************************************************

View file

@ -460,12 +460,12 @@ static bool has_time_passed(FAR struct timespec *curr,
FAR struct timespec *start,
unsigned int secs_since_start)
{
if ((long)((start->tv_sec + secs_since_start) - curr->tv_sec) == 0)
if ((start->tv_sec + secs_since_start) - curr->tv_sec == 0)
{
return start->tv_nsec <= curr->tv_nsec;
}
return (long)((start->tv_sec + secs_since_start) - curr->tv_sec) <= 0;
return (start->tv_sec + secs_since_start) - curr->tv_sec <= 0;
}
/****************************************************************************
@ -485,7 +485,7 @@ static bool time_has_passed_ms(FAR struct timespec *curr,
if (start->tv_sec < curr->tv_sec)
{
curr_msec += 1000 * ((long)(curr->tv_sec - start->tv_sec));
curr_msec += 1000 * (curr->tv_sec - start->tv_sec);
}
return (start_msec + msecs_since_start) <= curr_msec;
@ -773,7 +773,7 @@ static ssize_t sgp30_read(FAR struct file *filep, FAR char *buffer,
ts_sleep.tv_nsec += NSEC_PER_SEC;
}
if ((long)ts_sleep.tv_sec >= 0)
if (ts_sleep.tv_sec >= 0)
{
ret = nxsig_nanosleep(&ts_sleep, NULL);
if (ret == -EINTR)

View file

@ -263,12 +263,12 @@ static bool has_time_passed(struct timespec curr,
struct timespec start,
unsigned int secs_since_start)
{
if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0)
if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0)
{
return start.tv_nsec <= curr.tv_nsec;
}
return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0;
return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0;
}
/****************************************************************************

View file

@ -523,12 +523,12 @@ static int sht4x_read(FAR struct sht4x_dev_s *priv,
static bool has_time_passed(struct timespec curr, struct timespec start,
unsigned int secs_since_start)
{
if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0)
if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0)
{
return start.tv_nsec <= curr.tv_nsec;
}
return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0;
return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0;
}
/****************************************************************************

View file

@ -452,12 +452,12 @@ static bool has_time_passed(struct timespec curr,
struct timespec start,
unsigned int secs_since_start)
{
if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0)
if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0)
{
return start.tv_nsec <= curr.tv_nsec;
}
return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0;
return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0;
}
/****************************************************************************

View file

@ -406,12 +406,12 @@ static bool has_time_passed(struct timespec curr,
struct timespec start,
unsigned int secs_since_start)
{
if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0)
if ((start.tv_sec + secs_since_start) - curr.tv_sec == 0)
{
return start.tv_nsec <= curr.tv_nsec;
}
return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0;
return (start.tv_sec + secs_since_start) - curr.tv_sec <= 0;
}
/****************************************************************************

View file

@ -168,9 +168,9 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
# endif
# else
# if defined(CONFIG_SYSLOG_TIMESTAMP_MS)
"[%5ju.%03ld] "
"[%5jd.%03ld] "
# else
"[%5ju.%06ld] "
"[%5jd.%06ld] "
# endif
# endif
#endif
@ -216,10 +216,10 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
# endif
# else
# if defined(CONFIG_SYSLOG_TIMESTAMP_MS)
, (uintmax_t)ts.tv_sec
, (intmax_t)ts.tv_sec
, ts.tv_nsec / NSEC_PER_MSEC
# else
, (uintmax_t)ts.tv_sec
, (intmax_t)ts.tv_sec
, ts.tv_nsec / NSEC_PER_USEC
# endif
# endif

View file

@ -27,6 +27,7 @@
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <errno.h>
#include <nuttx/debug.h>
@ -405,7 +406,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
return -EAGAIN;
}
rtcinfo("Setting time tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec);
rtcinfo("Setting time tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
/* Get the broken out time */

View file

@ -27,6 +27,7 @@
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <errno.h>
#include <nuttx/debug.h>
@ -498,7 +499,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
return -EAGAIN;
}
rtcinfo("Setting time tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec);
rtcinfo("Setting time tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
/* Get the broken out time */

View file

@ -24,6 +24,8 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/debug.h>
#include <nuttx/kmalloc.h>
@ -116,8 +118,8 @@ static int ptp_clock_dummy_gettime(FAR struct ptp_lowerhalf_s *lower,
sts->post_ts.tv_nsec = ts->tv_nsec;
}
ptpinfo("ptp_clock_dummy_gettime sec:%ld, nsec:%ld\n", ts->tv_sec,
ts->tv_nsec);
ptpinfo("ptp_clock_dummy_gettime sec:%jd, nsec:%ld\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
return 0;
}
@ -144,16 +146,16 @@ ptp_clock_dummy_getcrosststamp(FAR struct ptp_lowerhalf_s *lower,
cts->monoraw.tv_sec = ts.tv_sec;
cts->monoraw.tv_nsec = ts.tv_sec;
ptpinfo("ptp_clock_dummy_getcrosststamp sec:%ld, nsec:%ld\n",
(long)ts.tv_sec, ts.tv_nsec);
ptpinfo("ptp_clock_dummy_getcrosststamp sec:%jd, nsec:%ld\n",
(intmax_t)ts.tv_sec, ts.tv_nsec);
return 0;
}
static int ptp_clock_dummy_settime(FAR struct ptp_lowerhalf_s *lower,
FAR const struct timespec *ts)
{
ptpinfo("ptp_clock_dummy_settime sec:%ld, nsec:%ld\n", (long)ts->tv_sec,
ts->tv_nsec);
ptpinfo("ptp_clock_dummy_settime sec:%jd, nsec:%ld\n",
(intmax_t)ts->tv_sec, ts->tv_nsec);
return 0;
}

View file

@ -27,6 +27,7 @@
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <errno.h>
#include <nuttx/debug.h>
@ -393,7 +394,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
return -EAGAIN;
}
rtcinfo("Setting time tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec);
rtcinfo("Setting time tp=(%jd,%ld)\n", (intmax_t)tp->tv_sec, tp->tv_nsec);
/* Get the broken out time */

View file

@ -390,7 +390,7 @@ uint32_t fat_systime2fattime(void)
{
/* Break done the seconds in date and time units */
if (gmtime_r((FAR const time_t *)&ts.tv_sec, &tm) != NULL)
if (gmtime_r(&ts.tv_sec, &tm) != NULL)
{
/* FAT can only represent dates since 1980. struct tm can
* represent dates since 1900.

View file

@ -2420,11 +2420,11 @@ static int nfs_statfs(FAR struct inode *mountpt, FAR struct statfs *sbp)
sfp = (FAR struct rpc_reply_fsstat *)nmp->nm_iobuffer;
sbp->f_bsize = NFS_FABLKSIZE;
tquad = fxdr_hyper(&sfp->fsstat.sf_tbytes);
sbp->f_blocks = tquad / (uint64_t) NFS_FABLKSIZE;
sbp->f_blocks = tquad / NFS_FABLKSIZE;
tquad = fxdr_hyper(&sfp->fsstat.sf_fbytes);
sbp->f_bfree = tquad / (uint64_t) NFS_FABLKSIZE;
sbp->f_bfree = tquad / NFS_FABLKSIZE;
tquad = fxdr_hyper(&sfp->fsstat.sf_abytes);
sbp->f_bavail = tquad / (uint64_t) NFS_FABLKSIZE;
sbp->f_bavail = tquad / NFS_FABLKSIZE;
tquad = fxdr_hyper(&sfp->fsstat.sf_tfiles);
sbp->f_files = tquad;
tquad = fxdr_hyper(&sfp->fsstat.sf_ffiles);

View file

@ -235,9 +235,9 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr,
/* Generate output for maximum time pre-emption disabled */
linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu",
(unsigned long)maxtime.tv_sec,
(unsigned long)maxtime.tv_nsec);
linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%jd.%09ld",
(intmax_t)maxtime.tv_sec,
maxtime.tv_nsec);
copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset);
totalsize += copysize;
@ -269,9 +269,9 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr,
/* Generate output for maximum time in a critical section */
linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu",
(unsigned long)maxtime.tv_sec,
(unsigned long)maxtime.tv_nsec);
linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%jd.%09ld",
(intmax_t)maxtime.tv_sec,
maxtime.tv_nsec);
copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset);
totalsize += copysize;
@ -303,9 +303,9 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr,
/* Generate output for max busywait time to enter csection(get spinlock) */
linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu",
(unsigned long)maxtime.tv_sec,
(unsigned long)maxtime.tv_nsec);
linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%jd.%09ld",
(intmax_t)maxtime.tv_sec,
maxtime.tv_nsec);
copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset);
totalsize += copysize;
@ -335,10 +335,10 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s *attr,
/* Generate output for all busywait time to enter csection(get spinlock) */
linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%lu.%09lu %2"
linesize = procfs_snprintf(attr->line, CRITMON_LINELEN, ",%jd.%09ld %2"
PRId32 ".%04" PRId32 "%%",
(unsigned long)all_time.tv_sec,
(unsigned long)all_time.tv_nsec,
(intmax_t)all_time.tv_sec,
all_time.tv_nsec,
rate / 10000, rate % 10000);
copysize = procfs_memcpy(attr->line, linesize, buffer, buflen, offset);

View file

@ -791,9 +791,9 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile,
/* Generate output for maximum time pre-emption disabled */
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%lu.%09lu %p,",
(unsigned long)maxtime.tv_sec,
(unsigned long)maxtime.tv_nsec,
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%jd.%09ld %p,",
(intmax_t)maxtime.tv_sec,
maxtime.tv_nsec,
tcb->preemp_max_caller);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
&offset);
@ -827,9 +827,9 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile,
/* Generate output for maximum time in a critical section */
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%lu.%09lu %p,",
(unsigned long)maxtime.tv_sec,
(unsigned long)maxtime.tv_nsec,
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%jd.%09ld %p,",
(intmax_t)maxtime.tv_sec,
maxtime.tv_nsec,
tcb->crit_max_caller);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
&offset);
@ -863,9 +863,9 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile,
/* Generate output for max busywait time */
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%lu.%09lu %p,",
(unsigned long)maxtime.tv_sec,
(unsigned long)maxtime.tv_nsec,
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%jd.%09ld %p,",
(intmax_t)maxtime.tv_sec,
maxtime.tv_nsec,
tcb->busywait_max_caller);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
&offset);
@ -891,9 +891,9 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile,
/* Generate output for all busywait time */
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%lu.%09lu,",
(unsigned long)maxtime.tv_sec,
(unsigned long)maxtime.tv_nsec);
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, "%jd.%09ld,",
(intmax_t)maxtime.tv_sec,
maxtime.tv_nsec);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
&offset);
@ -929,11 +929,11 @@ static ssize_t proc_critmon(FAR struct proc_file_s *procfile,
*/
linesize = procfs_snprintf(procfile->line, STATUS_LINELEN,
"%lu.%09lu,%lu.%09lu\n",
(unsigned long)maxtime.tv_sec,
(unsigned long)maxtime.tv_nsec,
(unsigned long)runtime.tv_sec,
(unsigned long)(runtime.tv_nsec));
"%jd.%09ld,%jd.%09ld\n",
(intmax_t)maxtime.tv_sec,
maxtime.tv_nsec,
(intmax_t)runtime.tv_sec,
runtime.tv_nsec);
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining,
&offset);

View file

@ -49,5 +49,5 @@ hrtime_t gethrtime(void)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (hrtime_t)1000000000 * ts.tv_sec + ts.tv_nsec;
return 1000000000 * ts.tv_sec + ts.tv_nsec;
}

View file

@ -161,8 +161,7 @@ static int64_t get_signed_val(FAR struct type_descriptor *type,
uint64_t mask = (1llu << bits) - 1;
uint64_t ret = (uintptr_t)val & mask;
return (int64_t)(((ret & (1llu << (bits - 1))) != 0) ?
ret | ~mask : ret);
return ret & (1llu << (bits - 1)) != 0 ? ret | ~mask : ret;
}
return *(FAR int64_t *)val;

View file

@ -202,7 +202,7 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta)
if (delta)
{
adjust_usec = (long long)delta->tv_sec * USEC_PER_SEC + delta->tv_usec;
adjust_usec = delta->tv_sec * USEC_PER_SEC + delta->tv_usec;
ret = adjtime_start(adjust_usec);
}

Some files were not shown because too many files have changed in this diff Show more