summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-01-27 22:21:41 -0500
committerIan Moffett <ian@osmora.org>2025-01-27 22:21:41 -0500
commitce697974b68a265b0ee02ef76b4a6d8d31f4f365 (patch)
tree0019084ba474eea09cc21f5c33f403e80cbd59dd
parent9bb4cca1abdb9789c98fbab4387bed3091cb6f26 (diff)
kernel: param: Add IN_RANGE macro
Signed-off-by: Ian Moffett <ian@osmora.org>
-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 7783b66..2e888ab 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))
+/*
+ * Checks if value, `v' is in range of least, 'l'
+ * and max, 'm'.
+ */
+#define IN_RANGE(V, L, M) (((V) >= (L)) && ((V) <= (M)))
+
/* Gives 1 if pointer is aligned */
#define PTR_ALIGNED(PTR, ALIGN) (!((uintptr_t)PTR & (ALIGN - 1)))