All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roland Dreier <rdreier@cisco.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
	Bart Van Assche <bart.vanassche@gmail.com>,
	David Dillow <dave@thedillows.org>
Subject: Re: [PATCH] log2.h: Macro-ize is_power_of_2() for use in BUILD_BUG_ON
Date: Wed, 06 Jan 2010 13:23:13 -0800	[thread overview]
Message-ID: <ada8wcbszb2.fsf@roland-alpha.cisco.com> (raw)
In-Reply-To: <20100106123306.ac85e557.akpm@linux-foundation.org> (Andrew Morton's message of "Wed, 6 Jan 2010 12:33:06 -0800")


 > We've had recurring struggles with various versions of gcc screwing up
 > constructs of this form and trying to emit the non-constant code when
 > the arg was clearly a compile-time constant.  One episode which comes
 > to mind was when we made changes to kmalloc().
 > 
 > Of course, that might not bite us in this case - it would need a lot of
 > coverage testing to find out.

Actually, after thinking about this a bit more I don't think this is
much of a risk in this case.  The bad case is where gcc gets the wrong
answer for __builtin_constant_p(), and in that case, we're left with the
status quo ante, ie a call to the original inline function implementation.

This will break a call to BUILD_BUG_ON() but that's visible at compile
time.  It's hard to think of a silent failure case that actually hurts
anything -- the macro and inline implementation are identical, except
that the macro implementation will work when gcc really needs a compile
time constant.

 - R.

      parent reply	other threads:[~2010-01-06 21:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06 20:21 [PATCH] log2.h: Macro-ize is_power_of_2() for use in BUILD_BUG_ON Roland Dreier
2010-01-06 20:33 ` Andrew Morton
2010-01-06 20:44   ` Roland Dreier
2010-01-06 21:15     ` David Dillow
2010-01-06 21:42     ` Andrew Morton
2010-01-06 23:02       ` [PATCH] Add BUILD_BUG_ON_NOT_POWER_OF_2() Roland Dreier
2010-01-06 23:09         ` Andrew Morton
2010-01-07  7:33         ` Bart Van Assche
2010-01-07  7:51           ` Roland Dreier
2010-01-07  8:36         ` Robert P. J. Day
2010-01-07 16:45           ` Stefan Richter
2010-01-06 21:23   ` Roland Dreier [this message]

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=ada8wcbszb2.fsf@roland-alpha.cisco.com \
    --to=rdreier@cisco.com \
    --cc=akpm@linux-foundation.org \
    --cc=bart.vanassche@gmail.com \
    --cc=dave@thedillows.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.