From 454cb0203b097e38de5550ca35691e1701bf563b Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 1 Oct 2016 22:59:58 -0500 Subject: [PATCH] Added workaround for armc assumptions on integer underflow With ARM Compiler 5.06u3, when the equeue_tickdiff function is inlined, the compiler treats the unsigned integer subtraction as undefined behaviour and assumes falsely the comparisons could never be true. The workaround is to an explicit cast, which politely reminds the compiler to emit the correct comparison. --- equeue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/equeue.c b/equeue.c index c362dc1..e099ba5 100644 --- a/equeue.c +++ b/equeue.c @@ -13,7 +13,7 @@ // calculate the relative-difference between absolute times while // correctly handling overflow conditions static inline int equeue_tickdiff(unsigned a, unsigned b) { - return (int)(a - b); + return (int)(unsigned)(a - b); } // calculate the relative-difference between absolute times, but