Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+13 -14
+2
tools/include/linux/compiler-gcc.h
··· 20 20 /* &a[0] degrades to a pointer: a different type from an array */ 21 21 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) 22 22 23 + #define noinline __attribute__((noinline)) 24 + 23 25 #define __noreturn __attribute__((noreturn)) 24 26 25 27 #define __printf(a, b) __attribute__((format(printf, a, b)))
+4
tools/include/linux/compiler.h
··· 17 17 # define __always_inline inline __attribute__((always_inline)) 18 18 #endif 19 19 20 + #ifndef noinline 21 + #define noinline 22 + #endif 23 + 20 24 /* Are two types/vars the same type (ignoring qualifiers)? */ 21 25 #ifndef __same_type 22 26 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
+1 -2
tools/perf/tests/bp_signal.c
··· 62 62 } 63 63 #endif 64 64 65 - __attribute__ ((noinline)) 66 - static int test_function(void) 65 + static noinline int test_function(void) 67 66 { 68 67 __test_function(&the_var); 69 68 the_var++;
+1 -2
tools/perf/tests/bp_signal_overflow.c
··· 28 28 29 29 static int overflows; 30 30 31 - __attribute__ ((noinline)) 32 - static int test_function(void) 31 + static noinline int test_function(void) 33 32 { 34 33 return time(NULL); 35 34 }
+5 -10
tools/perf/tests/dwarf-unwind.c
··· 76 76 return strcmp((const char *) symbol, funcs[idx]); 77 77 } 78 78 79 - __attribute__ ((noinline)) 80 - static int unwind_thread(struct thread *thread) 79 + static noinline int unwind_thread(struct thread *thread) 81 80 { 82 81 struct perf_sample sample; 83 82 unsigned long cnt = 0; ··· 107 108 108 109 static int global_unwind_retval = -INT_MAX; 109 110 110 - __attribute__ ((noinline)) 111 - static int compare(void *p1, void *p2) 111 + static noinline int compare(void *p1, void *p2) 112 112 { 113 113 /* Any possible value should be 'thread' */ 114 114 struct thread *thread = *(struct thread **)p1; ··· 126 128 return p1 - p2; 127 129 } 128 130 129 - __attribute__ ((noinline)) 130 - static int krava_3(struct thread *thread) 131 + static noinline int krava_3(struct thread *thread) 131 132 { 132 133 struct thread *array[2] = {thread, thread}; 133 134 void *fp = &bsearch; ··· 144 147 return global_unwind_retval; 145 148 } 146 149 147 - __attribute__ ((noinline)) 148 - static int krava_2(struct thread *thread) 150 + static noinline int krava_2(struct thread *thread) 149 151 { 150 152 return krava_3(thread); 151 153 } 152 154 153 - __attribute__ ((noinline)) 154 - static int krava_1(struct thread *thread) 155 + static noinline int krava_1(struct thread *thread) 155 156 { 156 157 return krava_2(thread); 157 158 }