summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-06-04 17:37:38 -0400
committerIan Moffett <ian@osmora.org>2024-06-04 17:37:38 -0400
commitbba9dc6afbd65a81e61093e1f16bd354fb34885e (patch)
tree2dc4069587b204dbbecb09f241bd0cdd0f31b91e
parent4f8e9e197cd55a4a7b05a782996d66a9ca1b212f (diff)
kernel: Add ALIGN_UP/ALIGN_DOWN macros
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/include/sys/param.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/include/sys/param.h b/sys/include/sys/param.h
index 91566ae..d6c5a2b 100644
--- a/sys/include/sys/param.h
+++ b/sys/include/sys/param.h
@@ -38,6 +38,10 @@
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+/* Align up/down a value */
+#define ALIGN_DOWN(value, align) ((value) & ~((align)-1))
+#define ALIGN_UP(value, align) (((value) + (align)-1) & ~((align)-1))
+
/* Bitmap helper macros */
#define setbit(a, b) ((a)[(b) >> 3] |= BIT(b % 8))
#define clrbit(a, b) ((a)[(b) >> 3] &= ~BIT(b % 8))