Skip to content

Commit 93ba3a7

Browse files
committed
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.
1 parent 646cc89 commit 93ba3a7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

events/equeue/equeue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// calculate the relative-difference between absolute times while
2525
// correctly handling overflow conditions
2626
static inline int equeue_tickdiff(unsigned a, unsigned b) {
27-
return (int)(a - b);
27+
return (int)(unsigned)(a - b);
2828
}
2929

3030
// calculate the relative-difference between absolute times, but

0 commit comments

Comments
 (0)