From bba9dc6afbd65a81e61093e1f16bd354fb34885e Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 4 Jun 2024 17:37:38 -0400 Subject: kernel: Add ALIGN_UP/ALIGN_DOWN macros Signed-off-by: Ian Moffett --- sys/include/sys/param.h | 4 ++++ 1 file changed, 4 insertions(+) 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)) -- cgit v1.2.3