Messages in this thread Patch in this message | | | From | Raag Jadav <> | Subject | [PATCH v1 1/6] compiler.h: Introduce helpers for identifying array and pointer types | Date | Mon, 20 Nov 2023 17:38:32 +0530 |
| |
Introduce is_array_type() and is_pointer_type() helpers, which compare the data type of provided argument against the enumeration values defined in typeclass.h using __builtin_classify_type() function and identify array and pointer types respectively.
Signed-off-by: Raag Jadav <raag.jadav@intel.com> --- include/linux/compiler.h | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index bb1339c7057b..b4f656002c0f 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -242,6 +242,11 @@ static inline void *offset_to_ptr(const int *off) #define is_signed_type(type) (((type)(-1)) < (__force type)1) #define is_unsigned_type(type) (!is_signed_type(type)) +/* Classify data type based on enum values in typeclass.h */ +#define is_array_type(x) (__builtin_classify_type(x) == 14) +#define is_pointer_type(x) (__builtin_classify_type(x) == 5) +#define is_array_or_pointer_type(x) (is_array_type(x) || is_pointer_type(x)) + /* * This is needed in functions which generate the stack canary, see * arch/x86/kernel/smpboot.c::start_secondary() for an example. -- 2.17.1
| |