]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/compiler.h
mfd: Switch WM8350 revision detection to a feature based model
[linux-2.6-omap-h63xx.git] / include / linux / compiler.h
index c25e525121f0ae5ab04a91ba1dd498b917a5a758..d95da1020f1c95d7b392eecb7739a0393e79c4a3 100644 (file)
@@ -36,12 +36,8 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 
 #ifdef __KERNEL__
 
-#if __GNUC__ >= 4
-# include <linux/compiler-gcc4.h>
-#elif __GNUC__ == 3 && __GNUC_MINOR__ >= 2
-# include <linux/compiler-gcc3.h>
-#else
-# error Sorry, your compiler is too old/not recognized.
+#ifdef __GNUC__
+#include <linux/compiler-gcc.h>
 #endif
 
 #define notrace __attribute__((no_instrument_function))
@@ -63,8 +59,16 @@ struct ftrace_branch_data {
        const char *func;
        const char *file;
        unsigned line;
-       unsigned long correct;
-       unsigned long incorrect;
+       union {
+               struct {
+                       unsigned long correct;
+                       unsigned long incorrect;
+               };
+               struct {
+                       unsigned long miss;
+                       unsigned long hit;
+               };
+       };
 };
 
 /*
@@ -77,32 +81,18 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 #define likely_notrace(x)      __builtin_expect(!!(x), 1)
 #define unlikely_notrace(x)    __builtin_expect(!!(x), 0)
 
-#define likely_check(x) ({                                             \
+#define __branch_check__(x, expect) ({                                 \
                        int ______r;                                    \
                        static struct ftrace_branch_data                \
                                __attribute__((__aligned__(4)))         \
-                               __attribute__((section("_ftrace_likely"))) \
+                               __attribute__((section("_ftrace_annotated_branch"))) \
                                ______f = {                             \
                                .func = __func__,                       \
                                .file = __FILE__,                       \
                                .line = __LINE__,                       \
                        };                                              \
                        ______r = likely_notrace(x);                    \
-                       ftrace_likely_update(&______f, ______r, 1);     \
-                       ______r;                                        \
-               })
-#define unlikely_check(x) ({                                           \
-                       int ______r;                                    \
-                       static struct ftrace_branch_data                \
-                               __attribute__((__aligned__(4)))         \
-                               __attribute__((section("_ftrace_unlikely"))) \
-                               ______f = {                             \
-                               .func = __func__,                       \
-                               .file = __FILE__,                       \
-                               .line = __LINE__,                       \
-                       };                                              \
-                       ______r = unlikely_notrace(x);                  \
-                       ftrace_likely_update(&______f, ______r, 0);     \
+                       ftrace_likely_update(&______f, ______r, expect); \
                        ______r;                                        \
                })
 
@@ -112,11 +102,37 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
  * written by Daniel Walker.
  */
 # ifndef likely
-#  define likely(x)    (__builtin_constant_p(x) ? !!(x) : likely_check(x))
+#  define likely(x)    (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1))
 # endif
 # ifndef unlikely
-#  define unlikely(x)  (__builtin_constant_p(x) ? !!(x) : unlikely_check(x))
+#  define unlikely(x)  (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0))
 # endif
+
+#ifdef CONFIG_PROFILE_ALL_BRANCHES
+/*
+ * "Define 'is'", Bill Clinton
+ * "Define 'if'", Steven Rostedt
+ */
+#define if(cond) if (__builtin_constant_p((cond)) ? !!(cond) :         \
+       ({                                                              \
+               int ______r;                                            \
+               static struct ftrace_branch_data                        \
+                       __attribute__((__aligned__(4)))                 \
+                       __attribute__((section("_ftrace_branch")))      \
+                       ______f = {                                     \
+                               .func = __func__,                       \
+                               .file = __FILE__,                       \
+                               .line = __LINE__,                       \
+                       };                                              \
+               ______r = !!(cond);                                     \
+               if (______r)                                            \
+                       ______f.hit++;                                  \
+               else                                                    \
+                       ______f.miss++;                                 \
+               ______r;                                                \
+       }))
+#endif /* CONFIG_PROFILE_ALL_BRANCHES */
+
 #else
 # define likely(x)     __builtin_expect(!!(x), 1)
 # define unlikely(x)   __builtin_expect(!!(x), 0)