aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper/stepcompress.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-06-05 21:25:37 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-06-20 09:26:10 -0400
commit189ebb4c7d5134296ce9e2bebe304a795b38ef89 (patch)
tree3b6c3249e9268b5bd0a87c50758e26146d867f0b /klippy/chelper/stepcompress.c
parentbedbfceafc39489dfcc6cf453b7d64df262455e5 (diff)
downloadkutter-189ebb4c7d5134296ce9e2bebe304a795b38ef89.tar.gz
kutter-189ebb4c7d5134296ce9e2bebe304a795b38ef89.tar.xz
kutter-189ebb4c7d5134296ce9e2bebe304a795b38ef89.zip
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper/stepcompress.c')
-rw-r--r--klippy/chelper/stepcompress.c7
1 files changed, 3 insertions, 4 deletions
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 <stdio.h> // fprintf
#include <stdlib.h> // malloc
#include <string.h> // 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)