diff options
author | Ian Moffett <ian@osmora.org> | 2024-06-04 17:37:38 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-06-04 17:37:38 -0400 |
commit | bba9dc6afbd65a81e61093e1f16bd354fb34885e (patch) | |
tree | 2dc4069587b204dbbecb09f241bd0cdd0f31b91e /sys | |
parent | 4f8e9e197cd55a4a7b05a782996d66a9ca1b212f (diff) |
kernel: Add ALIGN_UP/ALIGN_DOWN macros
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/include/sys/param.h | 4 |
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)) |