[PATCH v1 1/6] compiler.h: Introduce helpers for identifying array and pointer types
Raag Jadav
raag.jadav at intel.com
Mon Nov 20 04:08:32 PST 2023
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 at 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
More information about the linux-arm-kernel
mailing list