Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions benchmarks/cyclictest/cyclictest.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ static inline void tsnorm(struct timespec *ts)
static inline int64_t timediff_us(struct timespec t1, struct timespec t2)
{
int64_t ret;
ret = 1000000 * (int64_t) ((int) t1.tv_sec - (int) t2.tv_sec);
ret += (int64_t) ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
ret = 1000000 * (t1.tv_sec - t2.tv_sec);
ret += (t1.tv_nsec - t2.tv_nsec) / 1000;
return ret;
}

Expand All @@ -458,11 +458,11 @@ static inline int64_t timediff_us_timer(struct timer_status_s after,
t2 = after.timeleft;
if (t2 < t1)
{
ret = (int64_t) (t1 - t2);
ret = t1 - t2;
}
else
{
ret = (int64_t) (after.timeout - (t2 - t1));
ret = after.timeout - (t2 - t1);
}

return ret;
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/sd_bench/sd_bench_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ static uint64_t get_time_delta_us(const struct timespec *start,
const struct timespec *end)
{
uint64_t elapsed;
elapsed = (((uint64_t)end->tv_sec * NSEC_PER_SEC) + end->tv_nsec);
elapsed -= (((uint64_t)start->tv_sec * NSEC_PER_SEC) + start->tv_nsec);
elapsed = (end->tv_sec * NSEC_PER_SEC) + end->tv_nsec;
elapsed -= (start->tv_sec * NSEC_PER_SEC) + start->tv_nsec;
return elapsed / 1000.;
}

Expand Down
9 changes: 5 additions & 4 deletions examples/adjtime/adjtime_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
****************************************************************************/

#include <nuttx/config.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/time.h>

Expand Down Expand Up @@ -149,8 +150,8 @@ int main(int argc, FAR char *argv[])

parse_args(&delta, argc, argv);

printf("Delta time is %ld seconds and %ld micro seconds.\n",
(long)delta.tv_sec, delta.tv_usec);
printf("Delta time is %jd seconds and %ld micro seconds.\n",
(intmax_t)delta.tv_sec, delta.tv_usec);

/* Call adjtime function. */

Expand All @@ -161,8 +162,8 @@ int main(int argc, FAR char *argv[])
}
else
{
printf("Returned olddelta is %ld seconds and %ld micro seconds.\n",
(long)olddelta.tv_sec, olddelta.tv_usec);
printf("Returned olddelta is %jd seconds and %ld micro seconds.\n",
(intmax_t)olddelta.tv_sec, olddelta.tv_usec);
}

return ret;
Expand Down
4 changes: 2 additions & 2 deletions examples/charger/charger_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ int main(int argc, FAR char *argv[])
}

gettimeofday(&tv, NULL);
printf("%ju.%06ld: %d mV, %d mA\n",
(uintmax_t)tv.tv_sec, tv.tv_usec, voltage, current);
printf("%jd.%06ld: %d mV, %d mA\n",
(intmax_t)tv.tv_sec, tv.tv_usec, voltage, current);

close(fd);

Expand Down
7 changes: 4 additions & 3 deletions examples/netpkt/netpkt_ethercat.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <nuttx/config.h>

#include <stdint.h>
#include <stdio.h>
#include <time.h>

Expand Down Expand Up @@ -118,9 +119,9 @@ int main(int argc, FAR const char *argv[])

len = recvfrom(sockfd, recvbuff, 100, 0, NULL, NULL);
clock_gettime(CLOCK_REALTIME, &recv_time);
printf("Data recv: %d bytes, spent time %ld ns\n", len,
(recv_time.tv_sec - send_time.tv_sec) * NSEC_PER_SEC +
recv_time.tv_nsec - send_time.tv_nsec);
printf("Data recv: %d bytes, spent time %jd ns\n", len,
(intmax_t)(recv_time.tv_sec - send_time.tv_sec) *
NSEC_PER_SEC + recv_time.tv_nsec - send_time.tv_nsec);
usleep(1000);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/oneshot/oneshot_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ int main(int argc, FAR char *argv[])
return EXIT_FAILURE;
}

maxus = (uint64_t)ts.tv_sec * USEC_PER_SEC +
(uint64_t)ts.tv_nsec / NSEC_PER_USEC;
maxus = ts.tv_sec * USEC_PER_SEC +
ts.tv_nsec / NSEC_PER_USEC;

printf("Maximum delay is %" PRIu64 "\n", maxus);

Expand Down
6 changes: 2 additions & 4 deletions examples/watchdog/watchdog_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ int main(int argc, FAR char *argv[])
/* Get current time to calculate the elapsed time */

clock_gettime(CLOCK_REALTIME, &tnow);
current_time_ms = (uint64_t)((tnow.tv_sec * 1000)
+ (tnow.tv_nsec / 1000000));
current_time_ms = (tnow.tv_sec * 1000) + (tnow.tv_nsec / 1000000);
}

/* Then stop pinging */
Expand Down Expand Up @@ -345,8 +344,7 @@ int main(int argc, FAR char *argv[])
/* Get current time to calculate the elapsed time */

clock_gettime(CLOCK_REALTIME, &tnow);
current_time_ms = (uint64_t)((tnow.tv_sec * 1000)
+ (tnow.tv_nsec / 1000000));
current_time_ms = (tnow.tv_sec * 1000) + (tnow.tv_nsec / 1000000);
}

/* We should not get here */
Expand Down
2 changes: 1 addition & 1 deletion fsutils/mkfatfs/mkfatfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static 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.
Expand Down
6 changes: 3 additions & 3 deletions graphics/nxwm/src/chexcalculator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ void CHexCalculator::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)

if (m_result)
{
m_accum = (uint64_t)g_keyDesc[index].value;
m_accum = g_keyDesc[index].value;
}

// Otherwise, add the new value to the accumulator. The way
Expand All @@ -743,12 +743,12 @@ void CHexCalculator::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
else if (m_hexMode)
{
m_accum <<= 4;
m_accum |= (uint64_t)g_keyDesc[index].value;
m_accum |= g_keyDesc[index].value;
}
else
{
m_accum *= 10;
m_accum += (uint64_t)g_keyDesc[index].value;
m_accum += g_keyDesc[index].value;
}
updateText();
}
Expand Down
2 changes: 1 addition & 1 deletion graphics/tiff/tiff_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ static int tiff_datetime(FAR char *timbuf, unsigned int buflen)

/* Break the current time up into the format needed by strftime */

gmtime_r((FAR const time_t *)&ts.tv_sec, &tm);
gmtime_r(&ts.tv_sec, &tm);

/* Convert the current time to TIFF format */

Expand Down
2 changes: 1 addition & 1 deletion industry/nxmodbus/nxmb_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static inline uint64_t nxmb_util_clock_ms(void)
struct timespec ts;

clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
}

/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion lte/alt1250/usock_handlers/alt1250_ioctl_lwm2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ static int perform_m2m_applysetting(FAR struct alt1250_s *dev,
}

*usock_result = OK;
dev->lwm2m_apply_xid = (int64_t)xid;
dev->lwm2m_apply_xid = xid;

MODEM_STATE_INTENTRST(dev);
altdevice_reset(dev->altfd);
Expand Down
20 changes: 10 additions & 10 deletions netutils/ntpclient/ntpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static int32_t ntp_nsecpart(int64_t time)
{
/* Get fraction part converted to nanoseconds. */

return (((int64_t)((uint64_t)time << 32) >> 32) * NSEC_PER_SEC) >> 32;
return (((time << 32) >> 32) * NSEC_PER_SEC) >> 32;
}

/****************************************************************************
Expand All @@ -589,7 +589,7 @@ static uint64_t timespec2ntp(FAR const struct timespec *ts)

/* Set seconds part. */

ntp_time += (uint64_t)(ts->tv_sec) << 32;
ntp_time += ts->tv_sec << 32;

return ntp_time;
}
Expand Down Expand Up @@ -647,8 +647,8 @@ static void ntpc_calculate_offset(FAR int64_t *offset, FAR int64_t *delay,
* http://nicolas.aimon.fr/2014/12/05/timesync/
*/

*offset = (int64_t)((remote_recvtime / 2 - local_xmittime / 2) +
(remote_xmittime / 2 - local_recvtime / 2));
*offset = (remote_recvtime / 2 - local_xmittime / 2) +
(remote_xmittime / 2 - local_recvtime / 2);

/* Calculate roundtrip delay. */

Expand Down Expand Up @@ -707,13 +707,13 @@ static void ntpc_settime(int64_t offset, FAR struct timespec *start_realtime,

diffms_real = curr_realtime.tv_sec - start_realtime->tv_sec;
diffms_real *= 1000;
diffms_real += (int64_t)(curr_realtime.tv_nsec -
start_realtime->tv_nsec) / (1000 * 1000);
diffms_real += (curr_realtime.tv_nsec -
start_realtime->tv_nsec) / (1000 * 1000);

diffms_mono = curr_monotonic.tv_sec - start_monotonic->tv_sec;
diffms_mono *= 1000;
diffms_mono += (int64_t)(curr_monotonic.tv_nsec -
start_monotonic->tv_nsec) / (1000 * 1000);
diffms_mono += (curr_monotonic.tv_nsec -
start_monotonic->tv_nsec) / (1000 * 1000);

/* Detect if real-time has been altered by other task. */

Expand Down Expand Up @@ -1489,14 +1489,14 @@ static int ntpc_daemon(int argc, FAR char **argv)

if (offset1 > 0 && offset2 > 0)
{
offset = ((uint64_t)offset1 + (uint64_t)offset2) / 2;
offset = (offset1 + offset2) / 2;
}
else if (offset1 < 0 && offset2 < 0)
{
offset1 = -offset1;
offset2 = -offset2;

offset = ((uint64_t)offset1 + (uint64_t)offset2) / 2;
offset = (offset1 + offset2) / 2;

offset = -offset;
}
Expand Down
20 changes: 10 additions & 10 deletions netutils/ptpd/ptpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ static int ptp_adjtime(FAR struct ptp_state_s *state, int64_t delta_ns,
struct timeval delta;

delta.tv_sec = delta_ns / NSEC_PER_SEC;
delta_ns -= (int64_t)delta.tv_sec * NSEC_PER_SEC;
delta_ns -= delta.tv_sec * NSEC_PER_SEC;
delta.tv_usec = delta_ns / NSEC_PER_USEC;
return adjtime(&delta, NULL);
}
Expand Down Expand Up @@ -1030,11 +1030,11 @@ static int ptp_update_local_clock(FAR struct ptp_state_s *state,
const int64_t adj_limit_ns = CONFIG_NETUTILS_PTPD_SETTIME_THRESHOLD_MS
* (int64_t)NSEC_PER_MSEC;

ptpinfo("Local time: %lld.%09ld, remote time %lld.%09ld\n",
(long long)local_timestamp->tv_sec,
(long)local_timestamp->tv_nsec,
(long long)remote_timestamp->tv_sec,
(long)remote_timestamp->tv_nsec);
ptpinfo("Local time: %jd.%09ld, remote time %jd.%09ld\n",
(intmax_t)local_timestamp->tv_sec,
local_timestamp->tv_nsec,
(intmax_t)remote_timestamp->tv_sec,
remote_timestamp->tv_nsec);

delta_ns = timespec_delta_ns(remote_timestamp, local_timestamp);
delta_ns += state->path_delay_ns;
Expand Down Expand Up @@ -1062,8 +1062,8 @@ static int ptp_update_local_clock(FAR struct ptp_state_s *state,

if (ret == OK)
{
ptpinfo("Jumped to timestamp %lld.%09ld s\n",
(long long)new_time.tv_sec, (long)new_time.tv_nsec);
ptpinfo("Jumped to timestamp %jd.%09ld s\n",
(intmax_t)new_time.tv_sec, new_time.tv_nsec);
}
else
{
Expand Down Expand Up @@ -1241,7 +1241,7 @@ static void ptp_add_correction_time(FAR const uint8_t *correction,
| (((uint64_t)correction[4]) << 8)
| (((uint64_t)correction[5]) << 0);

ptpinfo("correction before: %lld.%09ld\n", (long long)ts->tv_sec,
ptpinfo("correction before: %jd.%09ld\n", (intmax_t)ts->tv_sec,
ts->tv_nsec);

ts->tv_sec += correction_time / NSEC_PER_SEC;
Expand All @@ -1252,7 +1252,7 @@ static void ptp_add_correction_time(FAR const uint8_t *correction,
ts->tv_sec += 1;
}

ptpinfo("correction after: %lld.%09ld\n", (long long)ts->tv_sec,
ptpinfo("correction after: %jd.%09ld\n", (intmax_t)ts->tv_sec,
ts->tv_nsec);
}

Expand Down
13 changes: 7 additions & 6 deletions nshlib/nsh_timcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <nuttx/config.h>

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -120,15 +121,15 @@ static inline int date_showtime(FAR struct nsh_vtbl_s *vtbl,

if (utc)
{
if (gmtime_r((FAR const time_t *)&ts.tv_sec, &tm) == NULL)
if (gmtime_r(&ts.tv_sec, &tm) == NULL)
{
nsh_error(vtbl, g_fmtcmdfailed, name, "gmtime_r", NSH_ERRNO);
return ERROR;
}
}
else
{
if (localtime_r((FAR const time_t *)&ts.tv_sec, &tm) == NULL)
if (localtime_r(&ts.tv_sec, &tm) == NULL)
{
nsh_error(vtbl, g_fmtcmdfailed, name, "localtime_r", NSH_ERRNO);
return ERROR;
Expand Down Expand Up @@ -354,8 +355,8 @@ int cmd_time(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
}

diff.tv_nsec = end.tv_nsec - start.tv_nsec;
nsh_output(vtbl, "\n%lu.%04lu sec\n", (unsigned long)diff.tv_sec,
(unsigned long)diff.tv_nsec / 100000);
nsh_output(vtbl, "\n%jd.%04ld sec\n", (intmax_t)diff.tv_sec,
diff.tv_nsec / 100000);
}
}

Expand Down Expand Up @@ -489,7 +490,7 @@ int cmd_timedatectl(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
return ERROR;
}

if (localtime_r((FAR const time_t *)&ts.tv_sec, &tm) == NULL)
if (localtime_r(&ts.tv_sec, &tm) == NULL)
{
nsh_error(vtbl, g_fmtcmdfailed, argv[0], "localtime_r", NSH_ERRNO);
return ERROR;
Expand All @@ -508,7 +509,7 @@ int cmd_timedatectl(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
tm.tm_gmtoff);
nsh_output(vtbl, " Local time: %s %s\n", timbuf, tm.tm_zone);

if (gmtime_r((FAR const time_t *)&ts.tv_sec, &tm) == NULL)
if (gmtime_r(&ts.tv_sec, &tm) == NULL)
{
nsh_error(vtbl, g_fmtcmdfailed, argv[0], "gmtime_r", NSH_ERRNO);
return ERROR;
Expand Down
4 changes: 2 additions & 2 deletions system/coredump/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ static void coredump_restore(FAR char *savepath, size_t maxfile)
/* 'date -d @$(printf "%d" 0x6720C67E)' restore utc to date */

ret = snprintf(dumppath, sizeof(dumppath),
"%s/%.16s-%llx"COREDUMP_FILE_SUFFIX,
"%s/%.16s-%jx"COREDUMP_FILE_SUFFIX,
savepath, info.name.version,
(unsigned long long)info.time.tv_sec);
(intmax_t)info.time.tv_sec);

while (ret--)
{
Expand Down
4 changes: 2 additions & 2 deletions system/dd/dd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ int main(int argc, FAR char **argv)
#ifdef CONFIG_SYSTEM_DD_STATS
clock_gettime(CLOCK_MONOTONIC, &ts1);

elapsed = (((uint64_t)ts1.tv_sec * NSEC_PER_SEC) + ts1.tv_nsec);
elapsed -= (((uint64_t)ts0.tv_sec * NSEC_PER_SEC) + ts0.tv_nsec);
elapsed = (ts1.tv_sec * NSEC_PER_SEC) + ts1.tv_nsec;
elapsed -= (ts0.tv_sec * NSEC_PER_SEC) + ts0.tv_nsec;
elapsed /= NSEC_PER_USEC; /* usec */

fprintf(stderr, "%" PRIu64 " bytes (%" PRIu32 " blocks) copied, %u usec, ",
Expand Down
Loading
Loading