aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-12-20 01:08:12 -0500
committerIan Moffett <ian@osmora.org>2024-12-20 01:08:12 -0500
commita3c9b47cc63f67a09abd098ef25a7e5827f0c185 (patch)
tree12d87c80fc43d95db7aa19e8fd4aa135b2a70f22 /sys
parenta455da84568992df1e84ba3ff45ff229ecd7c5be (diff)
kernel: param: Add ptr helpers
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/include/sys/param.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/include/sys/param.h b/sys/include/sys/param.h
index 612e282..7783b66 100644
--- a/sys/include/sys/param.h
+++ b/sys/include/sys/param.h
@@ -57,6 +57,12 @@
#define COMBINE16(h, l) ((uint32_t)((uint32_t)(h) << 16) | (l))
#define COMBINE32(h, l) ((uint64_t)((uint64_t)(h) << 32) | (l))
+/* Gives 1 if pointer is aligned */
+#define PTR_ALIGNED(PTR, ALIGN) (!((uintptr_t)PTR & (ALIGN - 1)))
+
+/* Adds a value to a pointer */
+#define PTR_OFFSET(PTR, OFF) ((void *)((uintptr_t)PTR + OFF))
+
#define NELEM(a) (sizeof(a) / sizeof(a[0]))
#endif /* _SYS_PARAM_H_ */