From 189ebb4c7d5134296ce9e2bebe304a795b38ef89 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 5 Jun 2018 21:25:37 -0400 Subject: chelper: Add compiler.h header Add the compiler.h header file to the chelper code - this adds a number of useful gcc definitions. Signed-off-by: Kevin O'Connor --- klippy/chelper/stepcompress.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'klippy/chelper/stepcompress.c') diff --git a/klippy/chelper/stepcompress.c b/klippy/chelper/stepcompress.c index 7bb72b96..c65bb431 100644 --- a/klippy/chelper/stepcompress.c +++ b/klippy/chelper/stepcompress.c @@ -20,6 +20,7 @@ #include // fprintf #include // malloc #include // memset +#include "compiler.h" // DIV_ROUND_UP #include "pyhelper.h" // errorf #include "serialqueue.h" // struct queue_message @@ -44,12 +45,10 @@ struct stepcompress { * Step compression ****************************************************************/ -#define DIV_UP(n,d) (((n) + (d) - 1) / (d)) - static inline int32_t idiv_up(int32_t n, int32_t d) { - return (n>=0) ? DIV_UP(n,d) : (n/d); + return (n>=0) ? DIV_ROUND_UP(n,d) : (n/d); } static inline int32_t @@ -116,7 +115,7 @@ compress_bisect_add(struct stepcompress *sc) int32_t nextaddfactor = nextcount*(nextcount-1)/2; int32_t c = add*nextaddfactor; if (nextmininterval*nextcount < nextpoint.minp - c) - nextmininterval = DIV_UP(nextpoint.minp - c, nextcount); + nextmininterval = DIV_ROUND_UP(nextpoint.minp - c, nextcount); if (nextmaxinterval*nextcount > nextpoint.maxp - c) nextmaxinterval = (nextpoint.maxp - c) / nextcount; if (nextmininterval > nextmaxinterval) -- cgit v1.2.3-70-g09d2