[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231121103829.10027-2-raag.jadav@intel.com>
Date: Tue, 21 Nov 2023 16:08:24 +0530
From: Raag Jadav <raag.jadav@...el.com>
To: mika.westerberg@...ux.intel.com, andriy.shevchenko@...ux.intel.com,
rafael@...nel.org, lenb@...nel.org, robert.moore@...el.com,
ardb@...nel.org, will@...nel.org, mark.rutland@....com
Cc: linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
acpica-devel@...ts.linuxfoundation.org, linux-efi@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
mallikarjunappa.sangannavar@...el.com, bala.senthil@...el.com,
Raag Jadav <raag.jadav@...el.com>
Subject: [PATCH v2 1/6] compiler.h: Introduce helpers for identifying array and pointer types
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@...el.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
Powered by blists - more mailing lists