summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2023-12-19 22:11:08 -0500
committerIan Moffett <ian@osmora.org>2023-12-19 22:11:08 -0500
commitea0290d541d985f84e77f1e8f3b8fadfb5fa9fd9 (patch)
tree77b388fb325598b3d59956b1f9c9124cc926869b /sys
parente07242e3a1589742772732c4e739f78bdab20a00 (diff)
kernel: cdefs: Add extra helpers
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/include/sys/cdefs.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/include/sys/cdefs.h b/sys/include/sys/cdefs.h
index de353be..dc47b77 100644
--- a/sys/include/sys/cdefs.h
+++ b/sys/include/sys/cdefs.h
@@ -115,6 +115,15 @@
/* Computes 2^x i.e 2 to the power of 'x' */
#define __POW2(x) (1ULL << x)
+/* Combine two 8-bit values into a 16-bit value */
+#define __COMBINE8(HI, LO) ((uint16_t)((uint8_t)HI << 8) | LO)
+
+/* Combine two 16-bit values into a 32-bit value */
+#define __COMBINE16(HI, LO) ((uint32_t)((uint16_t)HI << 16) | LO)
+
+/* Combine two 32-bit values into a 64-bit value */
+#define __COMBINE32(HI, LO) ((uint64_t)((uint16_t)HI << 32) | LO)
+
/*
* Used to give metadata to
* a specific module. Example