From fbb0bcffc19e2b0ff26cfb6d85e0ee2719cc9c88 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 6 Jun 2024 15:11:52 -0400 Subject: kernel: param: Add bit combining macros Signed-off-by: Ian Moffett --- sys/include/sys/param.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/include/sys/param.h b/sys/include/sys/param.h index d6c5a2b..a35a094 100644 --- a/sys/include/sys/param.h +++ b/sys/include/sys/param.h @@ -47,6 +47,11 @@ #define clrbit(a, b) ((a)[(b) >> 3] &= ~BIT(b % 8)) #define testbit(a, b) (ISSET((a)[(b) >> 3], BIT(b % 8))) +/* Combine bits */ +#define COMBINE8(h, l) ((uint16_t)((uint16_t)(h) << 8) | (l)) +#define COMBINE16(h, l) ((uint32_t)((uint32_t)(h) << 16) | (l)) +#define COMBINE32(h, l) ((uint64_t)((uint64_t)(h) << 32) | (l)) + #define NELEM(a) (sizeof(a) / sizeof(a[0])) #endif /* _SYS_PARAM_H_ */ -- cgit v1.2.3