From: David Howells <dhowells@redhat.com>
To: Qian Cai <cai@lca.pw>
Cc: dhowells@redhat.com, akpm@linux-foundation.org,
davem@davemloft.net, arnd@arndb.de, jakub@redhat.com,
ndesaulniers@google.com, morbo@google.com, jyknight@google.com,
natechancellor@gmail.com, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] asm-generic: fix -Wtype-limits compiler warnings
Date: Wed, 24 Jul 2019 08:49:31 +0100 [thread overview]
Message-ID: <31573.1563954571@warthog.procyon.org.uk> (raw)
Message-ID: <20190724074931.Q4JaAxHRos2pCaah4tjarnh0Y1Yjz-VoNmpy4-T3F2o@z> (raw)
In-Reply-To: <1563914986-26502-1-git-send-email-cai@lca.pw>
Qian Cai <cai@lca.pw> wrote:
> Fix it by moving almost all of this multi-line macro into a proper
> function __get_order(), and leave get_order() as a single-line macro in
> order to avoid compilation errors.
The idea was that you could compile-time initialise a global variable with
get_order():
int a = get_order(SOME_MACRO);
This is the same reason that ilog2() is a macro:
int a = ilog2(SOME_MACRO);
See the banner comment on get_order():
* This function may be used to initialise variables with compile time
* evaluations of constants.
If you're moving the constant branch into __get_order(), an inline function,
then we'll no longer be able to do this and you need to modify the comment
too. In fact, would there still be a point in having the get_order() macro?
Also, IIRC, older versions of gcc see __builtin_constant_p(n) == 0 inside an
function, inline or otherwise, even if the passed-in argument *is* constant.
David
next prev parent reply other threads:[~2019-07-24 7:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 20:49 [PATCH] asm-generic: fix -Wtype-limits compiler warnings Qian Cai
2019-07-23 20:49 ` Qian Cai
2019-07-23 21:27 ` Andrew Morton
2019-07-23 21:27 ` Andrew Morton
2019-07-24 2:29 ` Nathan Chancellor
2019-07-24 2:29 ` Nathan Chancellor
2019-07-24 7:49 ` David Howells [this message]
2019-07-24 7:49 ` David Howells
2019-07-24 18:45 ` Qian Cai
2019-07-24 18:45 ` Qian Cai
2019-07-24 21:49 ` David Howells
2019-07-24 21:49 ` David Howells
2019-07-25 3:22 ` Qian Cai
2019-07-25 3:22 ` Qian Cai
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=31573.1563954571@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=cai@lca.pw \
--cc=davem@davemloft.net \
--cc=jakub@redhat.com \
--cc=jyknight@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=morbo@google.com \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
/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).