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

Falk Hueffner (falk.hueffner@student.uni-tuebingen.de)
13 Nov 2002 12:45:33 +0100


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/