From: Daniel Walker I used gcc 4.x when testing , so it must not effect those compilers. I managed to find a compiler that exibited this. It appears the compiler blows up while trying to evaluate constants . The patch below is suppose to give the compiler an easy way out. Instead of processing our code it just processes the constant .. This will also prevent the profiling of these constant values, since that's not very interesting anyway .. I tested on , pentium4-gcc (GCC) 3.4.3 (MontaVista 3.4.3-25.0.36.0501258 2005-08-14) Which was the only compiler I could find that had this issue .. The patch resolved it, and the profiling still worked. Signed-off-by: Daniel Walker Cc: Hua Zhong Signed-off-by: Andrew Morton --- include/linux/compiler.h | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff -puN include/linux/compiler.h~fix-gcc-3x-w-likely-profiling include/linux/compiler.h --- 25/include/linux/compiler.h~fix-gcc-3x-w-likely-profiling Thu Apr 27 16:17:52 2006 +++ 25-akpm/include/linux/compiler.h Thu Apr 27 16:17:52 2006 @@ -78,8 +78,14 @@ extern int do_check_likely(struct likeli do_check_likely(&likeliness, !!(exp)); \ }) -#define likely(x) __check_likely((x), 1) -#define unlikely(x) __check_likely((x), 0) +/* + * We check for constant values with __builtin_constant_p() since + * it's not interesting to profile them, and there is a compiler + * bug in gcc 3.x which blows up during constant evalution when + * CONFIG_PROFILE_LIKELY is turned on. + */ +#define likely(x) (__builtin_constant_p(x) ? (!!(x)) : __check_likely((x), 1)) +#define unlikely(x) (__builtin_constant_p(x) ? (!!(x)) : __check_likely((x), 0)) #else /* * Generic compiler-dependent macros required for kernel _