Re: [PATCH] include/asm-ARCH/page.h:get_order() Reorganize and optimize

From: Falk Hueffner (falk.hueffner@student.uni-tuebingen.de)
Date: Wed Nov 13 2002 - 06:45:33 EST


Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> writes:

> s = --s >> PAGE_SHIFT;

This code has undefined behaviour.

> if (likely (s) < s)

What is that supposed to do?

BTW, I just noticed

#define likely(x) __builtin_expect((x),1)

I think this should rather be

#define likely(x) __builtin_expect((x)!=0,1)

So people can write

if (likely(pointer))

and indeed some people seem to assume that already.

--- linux-2.5.47/include/linux/compiler.h~ 2002-11-11 04:28:25.000000000 +0100
+++ linux-2.5.47/include/linux/compiler.h 2002-11-13 12:44:05.000000000 +0100
@@ -10,7 +10,7 @@
 #define __builtin_expect(x, expected_value) (x)
 #endif
 
-#define likely(x) __builtin_expect((x),1)
+#define likely(x) __builtin_expect((x)!=0,1)
 #define unlikely(x) __builtin_expect((x),0)
 
 /* This macro obfuscates arithmetic on a variable address so that gcc

-- 
	Falk
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Nov 15 2002 - 22:00:28 EST