[lkml]   [2003]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] 2.4.22pre10: {,un}likely_p() macros for pointers
Chip Salzenberg wrote:
> > It's portable as long as the compiler is GCC :)
> No; wrong; please pay attention.

I was being facetious :)

> Both parameters of __builtin_expect() are long ints.

So it is broken if passed a "long long"? The documentation says "you
are limited to integral expressions".

...You're right. The documentation is wrong. It's strictly takes
"long int" arguments and returns a long.

> On an architecture where there's a pointer type larger than long[1],
> __builtin_expect() won't just warn, it'll *fail*.

A pointer really should fail on all architectures.
Fortunately you do get a warning.

> Also, on an architecture where a conversion of a null pointer to
> long results in a non-zero value[2], it'll *fail*. That makes it
> non-portable twice over. Wouldn't you agree?

[2] - I don't believe such architectures are supported by GCC, hence
the facetious comment.

> Since you are limited to integral expressions for exp, you should use constructions such as
> if (__builtin_expect (ptr != NULL, 1))
> error ();
> when testing pointer or floating-point values.

I think we all agree with this.

-- Jamie
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

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