public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/5] module_param: add __same_type convenience wrapper for __builtin_types_compatible_p
@ 2009-03-28 13:23 Rusty Russell
  0 siblings, 0 replies; only message in thread
From: Rusty Russell @ 2009-03-28 13:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton


Impact: new API

__builtin_types_compatible_p() is a little awkward to use: it takes two
types rather than types or variables, and it's just damn long.

(typeof(type) == type, so this works on types as well as vars).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 include/linux/compiler.h |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -260,6 +260,11 @@ void ftrace_likely_update(struct ftrace_
 # define __section(S) __attribute__ ((__section__(#S)))
 #endif
 
+/* Are two types/vars the same type (ignoring qualifiers)? */
+#ifndef __same_type
+# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
+#endif
+
 /*
  * Prevent the compiler from merging or refetching accesses.  The compiler
  * is also forbidden from reordering successive instances of ACCESS_ONCE(),


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-28 13:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-28 13:23 [PATCH 3/5] module_param: add __same_type convenience wrapper for __builtin_types_compatible_p Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox