aboutsummaryrefslogtreecommitdiff
path: root/include/apos/utils.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-09-20 14:17:18 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2021-09-20 14:17:18 +0300
commit68fcd6d027b88581992b4fb10ee1edc301e30678 (patch)
treec75ce91b2db43e562447b88958cff6eebaa96c98 /include/apos/utils.h
parent64405594929502951624942e2a9ca53077aba2ae (diff)
downloadkmi-68fcd6d027b88581992b4fb10ee1edc301e30678.tar.gz
kmi-68fcd6d027b88581992b4fb10ee1edc301e30678.zip
Some slight robustness improvements and obo errors
Diffstat (limited to 'include/apos/utils.h')
-rw-r--r--include/apos/utils.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/apos/utils.h b/include/apos/utils.h
index 45e7194..3855a37 100644
--- a/include/apos/utils.h
+++ b/include/apos/utils.h
@@ -11,4 +11,21 @@
#define MIN4(a, b, c, d) (MIN3(a, b, c) <= MIN3(b, c, d) ? MIN3(a, b, c) : MIN3(b, c, d))
/* etc... */
+#include <apos/types.h>
+
+static inline size_t align_up(size_t val, size_t a)
+{
+ size_t rem = val % a;
+
+ if (rem == 0)
+ return val;
+
+ return val + a - rem;
+}
+
+static inline size_t align_down(size_t val, size_t a)
+{
+ return val - (val % a);
+}
+
#endif /* APOS_UTILS_H */