summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-06-22 20:17:27 -0400
committerIan Moffett <ian@osmora.org>2025-06-22 20:32:01 -0400
commit549a3f6ea5e13e39f006125c0f46b79645384604 (patch)
tree9b0a1acac582dce63509968879696ea527892d7d
parentee365c6d442dbcffd05a64e6a8132f2ecbda79f6 (diff)
sys: param: Add PTR_NOFFSET define to sub pointers
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/include/sys/param.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/include/sys/param.h b/sys/include/sys/param.h
index c0a5686..7331d5f 100644
--- a/sys/include/sys/param.h
+++ b/sys/include/sys/param.h
@@ -67,8 +67,12 @@
/* Gives 1 if pointer is aligned */
#define PTR_ALIGNED(PTR, ALIGN) (!((uintptr_t)PTR & (ALIGN - 1)))
-/* Adds a value to a pointer */
+/*
+ * PTR_OFFSET: Adds an offset to the pointer
+ * PTR_NOFFSET: Subtracts a negative offset from the pointer
+ */
#define PTR_OFFSET(PTR, OFF) ((void *)((uintptr_t)PTR + OFF))
+#define PTR_NOFFSET(PTR, NOFF) ((void *)((uintptr_t)PTR - NOFF))
#define NELEM(a) (sizeof(a) / sizeof(a[0]))