lkml.org 
[lkml]   [2002]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] include/asm-ARCH/page.h:get_order() Reorganize and optimize
From
Date
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/

\
 
 \ /
  Last update: 2005-03-22 13:31    [W:0.075 / U:1.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site