From 7042ec883ed7f3ad2d0992913d314da98d163c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Gr=C3=A4f?= Date: Mon, 21 Oct 2019 12:23:02 +0000 Subject: [PATCH] Merged in jgraef-linetco/nuttx/fix-32bit-timer-overflow (pull request #1055) fix early timespec overflow if using 32 bit system timer Approved-by: Gregory Nutt --- sched/clock/clock_systimespec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sched/clock/clock_systimespec.c b/sched/clock/clock_systimespec.c index d222d5a4e05..513486802ff 100644 --- a/sched/clock/clock_systimespec.c +++ b/sched/clock/clock_systimespec.c @@ -173,15 +173,17 @@ int clock_systimespec(FAR struct timespec *ts) uint64_t msecs; uint64_t secs; uint64_t nsecs; +#define WIDE_CAST (uint64_t) #else clock_t msecs; clock_t secs; clock_t nsecs; +#define WIDE_CAST #endif /* Get the time since power-on in seconds and milliseconds */ - msecs = TICK2MSEC(clock_systimer()); + msecs = TICK2MSEC(WIDE_CAST clock_systimer()); secs = msecs / MSEC_PER_SEC; /* Return the elapsed time in seconds and nanoseconds */