diff options
Diffstat (limited to 'include/linux/util_macros.h')
| -rw-r--r-- | include/linux/util_macros.h | 14 | 
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/util_macros.h b/include/linux/util_macros.h index 72299f261b25..6bb460c3e818 100644 --- a/include/linux/util_macros.h +++ b/include/linux/util_macros.h @@ -2,6 +2,8 @@  #ifndef _LINUX_HELPER_MACROS_H_  #define _LINUX_HELPER_MACROS_H_ +#include <linux/math.h> +  #define __find_closest(x, a, as, op)					\  ({									\  	typeof(as) __fc_i, __fc_as = (as) - 1;				\ @@ -38,4 +40,16 @@   */  #define find_closest_descending(x, a, as) __find_closest(x, a, as, >=) +/** + * is_insidevar - check if the @ptr points inside the @var memory range. + * @ptr:	the pointer to a memory address. + * @var:	the variable which address and size identify the memory range. + * + * Evaluates to true if the address in @ptr lies within the memory + * range allocated to @var. + */ +#define is_insidevar(ptr, var)						\ +	((uintptr_t)(ptr) >= (uintptr_t)(var) &&			\ +	 (uintptr_t)(ptr) <  (uintptr_t)(var) + sizeof(var)) +  #endif  |