hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/include/linux/util_macros.h
....@@ -38,4 +38,16 @@
3838 */
3939 #define find_closest_descending(x, a, as) __find_closest(x, a, as, >=)
4040
41
+/**
42
+ * is_insidevar - check if the @ptr points inside the @var memory range.
43
+ * @ptr: the pointer to a memory address.
44
+ * @var: the variable which address and size identify the memory range.
45
+ *
46
+ * Evaluates to true if the address in @ptr lies within the memory
47
+ * range allocated to @var.
48
+ */
49
+#define is_insidevar(ptr, var) \
50
+ ((uintptr_t)(ptr) >= (uintptr_t)(var) && \
51
+ (uintptr_t)(ptr) < (uintptr_t)(var) + sizeof(var))
52
+
4153 #endif