aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/compiler.h24
1 files changed, 5 insertions, 19 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index c25e525121f0..0628a2013fae 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -77,32 +77,18 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
77#define likely_notrace(x) __builtin_expect(!!(x), 1) 77#define likely_notrace(x) __builtin_expect(!!(x), 1)
78#define unlikely_notrace(x) __builtin_expect(!!(x), 0) 78#define unlikely_notrace(x) __builtin_expect(!!(x), 0)
79 79
80#define likely_check(x) ({ \ 80#define __branch_check__(x, expect) ({ \
81 int ______r; \ 81 int ______r; \
82 static struct ftrace_branch_data \ 82 static struct ftrace_branch_data \
83 __attribute__((__aligned__(4))) \ 83 __attribute__((__aligned__(4))) \
84 __attribute__((section("_ftrace_likely"))) \ 84 __attribute__((section("_ftrace_annotated_branch"))) \
85 ______f = { \ 85 ______f = { \
86 .func = __func__, \ 86 .func = __func__, \
87 .file = __FILE__, \ 87 .file = __FILE__, \
88 .line = __LINE__, \ 88 .line = __LINE__, \
89 }; \ 89 }; \
90 ______r = likely_notrace(x); \ 90 ______r = likely_notrace(x); \
91 ftrace_likely_update(&______f, ______r, 1); \ 91 ftrace_likely_update(&______f, ______r, expect); \
92 ______r; \
93 })
94#define unlikely_check(x) ({ \
95 int ______r; \
96 static struct ftrace_branch_data \
97 __attribute__((__aligned__(4))) \
98 __attribute__((section("_ftrace_unlikely"))) \
99 ______f = { \
100 .func = __func__, \
101 .file = __FILE__, \
102 .line = __LINE__, \
103 }; \
104 ______r = unlikely_notrace(x); \
105 ftrace_likely_update(&______f, ______r, 0); \
106 ______r; \ 92 ______r; \
107 }) 93 })
108 94
@@ -112,10 +98,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
112 * written by Daniel Walker. 98 * written by Daniel Walker.
113 */ 99 */
114# ifndef likely 100# ifndef likely
115# define likely(x) (__builtin_constant_p(x) ? !!(x) : likely_check(x)) 101# define likely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1))
116# endif 102# endif
117# ifndef unlikely 103# ifndef unlikely
118# define unlikely(x) (__builtin_constant_p(x) ? !!(x) : unlikely_check(x)) 104# define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0))
119# endif 105# endif
120#else 106#else
121# define likely(x) __builtin_expect(!!(x), 1) 107# define likely(x) __builtin_expect(!!(x), 1)