linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: Chip Salzenberg <chip@pobox.com>
Cc: Willy Tarreau <willy@w.ods.org>,
	Albert Cahalan <albert@users.sourceforge.net>,
	linux-kernel mailing list <linux-kernel@vger.kernel.org>,
	davem@redhat.com
Subject: Re: [PATCH] 2.4.22pre10: {,un}likely_p() macros for pointers
Date: Mon, 11 Aug 2003 05:30:56 +0100	[thread overview]
Message-ID: <20030811043056.GG10446@mail.jlokier.co.uk> (raw)
In-Reply-To: <20030811023912.GJ24349@perlsupport.com>

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

  parent reply	other threads:[~2003-08-11  4:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-10  4:03 [PATCH] 2.4.22pre10: {,un}likely_p() macros for pointers Albert Cahalan
2003-08-10  7:29 ` Willy Tarreau
2003-08-10  8:02   ` Willy Tarreau
2003-08-11  1:23   ` Chip Salzenberg
2003-08-11  2:09     ` Jamie Lokier
2003-08-11  2:39       ` Chip Salzenberg
2003-08-11  4:02         ` Albert Cahalan
2003-08-11  4:30         ` Jamie Lokier [this message]
2003-08-11  5:30         ` Willy Tarreau
2003-08-11  5:42           ` Jamie Lokier
2003-08-11 13:09             ` Albert Cahalan
2003-08-11 18:55               ` Andrew Morton
2003-08-11 23:13                 ` Albert Cahalan
2003-08-13 19:42                   ` Jamie Lokier
2003-08-11  4:55   ` Jamie Lokier
2003-08-11  5:26     ` Willy Tarreau
2003-08-11  5:38       ` Jamie Lokier
  -- strict thread matches above, loose matches on Subject: below --
2003-08-05 12:44 Albert Cahalan
2003-08-09  0:21 ` Jamie Lokier
2003-08-09  8:13   ` Willy Tarreau
2003-08-09  8:51     ` David S. Miller
2003-08-09  9:36       ` Jamie Lokier
2003-08-09 10:10       ` Herbert Xu
2003-08-09 10:42       ` Alan Cox
2003-08-09 16:23         ` Jamie Lokier
2003-08-04 17:06 Chip Salzenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030811043056.GG10446@mail.jlokier.co.uk \
    --to=jamie@shareable.org \
    --cc=albert@users.sourceforge.net \
    --cc=chip@pobox.com \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@w.ods.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).