module_param: add __same_type convenience wrapper for __builtin_types_compatible_p

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, June 12, 2009 - 10:59 am

Gitweb:     http://git.kernel.org/linus/d2c123c27db841c6c11a63de9c144823d2b1ba76
Commit:     d2c123c27db841c6c11a63de9c144823d2b1ba76
Parent:     45fcc70c0b6ee0c508e1fdb5fef735c3546803f4
Author:     Rusty Russell <rusty@rustcorp.com.au>
AuthorDate: Fri Jun 12 21:46:56 2009 -0600
Committer:  Rusty Russell <rusty@rustcorp.com.au>
CommitDate: Fri Jun 12 21:46:57 2009 +0930

    module_param: add __same_type convenience wrapper for __builtin_types_compatible_p
    
    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 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 37bcb50..04fb513 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -261,6 +261,11 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 # 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(),
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
module_param: add __same_type convenience wrapper for __bu ..., Linux Kernel Mailing ..., (Fri Jun 12, 10:59 am)