summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2017-06-16 10:39:15 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-06-19 14:27:06 -0400
commit9dd4ca470e03334f95cc96529ba090921aac8eab (patch)
tree47b88e8ccc64b296973ec2786d43b40ce64aa0c9
parent0353631aa73e5e468fae1cd699bf860b59ba100d (diff)
tools: Adopt noinline from kernel sources
To have a more compact way to ask the compiler not to inline a function and to make tools/ source code look like kernel code. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-bis4pqxegt6gbm5dlqs937tn@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/include/linux/compiler-gcc.h2
-rw-r--r--tools/include/linux/compiler.h4
-rw-r--r--tools/perf/tests/bp_signal.c3
-rw-r--r--tools/perf/tests/bp_signal_overflow.c3
-rw-r--r--tools/perf/tests/dwarf-unwind.c15
5 files changed, 13 insertions, 14 deletions
diff --git a/tools/include/linux/compiler-gcc.h b/tools/include/linux/compiler-gcc.h
index 2846094aad4d..c13e6f7d5a2a 100644
--- a/tools/include/linux/compiler-gcc.h
+++ b/tools/include/linux/compiler-gcc.h
@@ -20,6 +20,8 @@
20/* &a[0] degrades to a pointer: a different type from an array */ 20/* &a[0] degrades to a pointer: a different type from an array */
21#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) 21#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
22 22
23#define noinline __attribute__((noinline))
24
23#define __noreturn __attribute__((noreturn)) 25#define __noreturn __attribute__((noreturn))
24 26
25#define __printf(a, b) __attribute__((format(printf, a, b))) 27#define __printf(a, b) __attribute__((format(printf, a, b)))
diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 23299d7e7160..8b129e314c7e 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -17,6 +17,10 @@
17# define __always_inline inline __attribute__((always_inline)) 17# define __always_inline inline __attribute__((always_inline))
18#endif 18#endif
19 19
20#ifndef noinline
21#define noinline
22#endif
23
20/* Are two types/vars the same type (ignoring qualifiers)? */ 24/* Are two types/vars the same type (ignoring qualifiers)? */
21#ifndef __same_type 25#ifndef __same_type
22# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 26# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index 8ba2c4618fe9..39bbb97cd30a 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -62,8 +62,7 @@ static void __test_function(volatile long *ptr)
62} 62}
63#endif 63#endif
64 64
65__attribute__ ((noinline)) 65static noinline int test_function(void)
66static int test_function(void)
67{ 66{
68 __test_function(&the_var); 67 __test_function(&the_var);
69 the_var++; 68 the_var++;
diff --git a/tools/perf/tests/bp_signal_overflow.c b/tools/perf/tests/bp_signal_overflow.c
index 89f92fa67cc4..3b1ac6f31b15 100644
--- a/tools/perf/tests/bp_signal_overflow.c
+++ b/tools/perf/tests/bp_signal_overflow.c
@@ -28,8 +28,7 @@
28 28
29static int overflows; 29static int overflows;
30 30
31__attribute__ ((noinline)) 31static noinline int test_function(void)
32static int test_function(void)
33{ 32{
34 return time(NULL); 33 return time(NULL);
35} 34}
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index dfe5c89e2049..3e56d08f7995 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -76,8 +76,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
76 return strcmp((const char *) symbol, funcs[idx]); 76 return strcmp((const char *) symbol, funcs[idx]);
77} 77}
78 78
79__attribute__ ((noinline)) 79static noinline int unwind_thread(struct thread *thread)
80static int unwind_thread(struct thread *thread)
81{ 80{
82 struct perf_sample sample; 81 struct perf_sample sample;
83 unsigned long cnt = 0; 82 unsigned long cnt = 0;
@@ -108,8 +107,7 @@ static int unwind_thread(struct thread *thread)
108 107
109static int global_unwind_retval = -INT_MAX; 108static int global_unwind_retval = -INT_MAX;
110 109
111__attribute__ ((noinline)) 110static noinline int compare(void *p1, void *p2)
112static int compare(void *p1, void *p2)
113{ 111{
114 /* Any possible value should be 'thread' */ 112 /* Any possible value should be 'thread' */
115 struct thread *thread = *(struct thread **)p1; 113 struct thread *thread = *(struct thread **)p1;
@@ -128,8 +126,7 @@ static int compare(void *p1, void *p2)
128 return p1 - p2; 126 return p1 - p2;
129} 127}
130 128
131__attribute__ ((noinline)) 129static noinline int krava_3(struct thread *thread)
132static int krava_3(struct thread *thread)
133{ 130{
134 struct thread *array[2] = {thread, thread}; 131 struct thread *array[2] = {thread, thread};
135 void *fp = &bsearch; 132 void *fp = &bsearch;
@@ -147,14 +144,12 @@ static int krava_3(struct thread *thread)
147 return global_unwind_retval; 144 return global_unwind_retval;
148} 145}
149 146
150__attribute__ ((noinline)) 147static noinline int krava_2(struct thread *thread)
151static int krava_2(struct thread *thread)
152{ 148{
153 return krava_3(thread); 149 return krava_3(thread);
154} 150}
155 151
156__attribute__ ((noinline)) 152static noinline int krava_1(struct thread *thread)
157static int krava_1(struct thread *thread)
158{ 153{
159 return krava_2(thread); 154 return krava_2(thread);
160} 155}