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
4 changes: 2 additions & 2 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 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
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 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 netutils/ntpclient/ntpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion 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
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
2 changes: 1 addition & 1 deletion testing/drivers/drivertest/drivertest_posix_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static uint64_t get_timestamp(void)
struct timespec ts;
uint64_t ms;
clock_gettime(CLOCK_MONOTONIC, &ts);
ms = (uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
ms = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
return ms;
}

Expand Down
4 changes: 2 additions & 2 deletions testing/drivers/sd_stress/sd_stress_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ static uint64_t get_time_delta(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
4 changes: 2 additions & 2 deletions testing/sched/getprime/getprime_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ int main(int argc, FAR char *argv[])
get_prime_in_parallel(n);
clock_gettime(CLOCK_REALTIME, &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_MSEC; /* msec */

printf("%s took %" PRIu64 " msec\n", argv[0], elapsed);
Expand Down
2 changes: 1 addition & 1 deletion testing/sched/pthread_mutex_perf/pthread_mutex_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void timespec_add(struct timespec *total, const struct timespec *diff)
static void timespec_avg(const struct timespec *total, int count,
struct timespec *avg)
{
uint64_t total_ns = (uint64_t)total->tv_sec * 1000000000 + total->tv_nsec;
uint64_t total_ns = total->tv_sec * 1000000000 + total->tv_nsec;
uint64_t avg_ns = total_ns / count;

avg->tv_sec = avg_ns / 1000000000;
Expand Down
Loading