aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-06-06 15:11:52 -0400
committerIan Moffett <ian@osmora.org>2024-06-06 15:11:52 -0400
commitfbb0bcffc19e2b0ff26cfb6d85e0ee2719cc9c88 (patch)
treefb8059537137523656955c3b017424a4bb811287
parente67e3a62edf7d1948d721e0fc62917906798add1 (diff)
kernel: param: Add bit combining macros
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/include/sys/param.h5
1 files changed, 5 insertions, 0 deletions
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_ */