From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH] bitfield: add FIELD_PREP_CONST()
Date: Wed, 18 Jan 2023 17:49:07 +0100 [thread overview]
Message-ID: <b2c78f45-345b-e3ec-20b1-9d18ee0c9f98@intel.com> (raw)
In-Reply-To: <3fe52061d5d9e3701f598add5c64f8b3583c31df.camel@sipsolutions.net>
From: Johannes Berg <johannes@sipsolutions.net>
Date: Wed, 18 Jan 2023 17:22:30 +0100
> On Wed, 2023-01-18 at 17:10 +0100, Alexander Lobakin wrote:
>>
>> Have you tried combining it with FIELD_PREP() using
>> __builtin_choose_expr() + __builtin_is_constexpr() (or
>> __builtin_constant_p() depending on which will satisfy the compiler)?
>> I'm not saying it's 100% possible, but worth trying.
>>
>
> I haven't tried it that way, but I tried rewriting FIELD_PREP() itself
> to be constant-compatible, and as soon as the compiler saw
> __builtin_constant_p() in the initializer it already complained that it
> was non-constant...
>
> I didn't think of __builtin_choose_expr, but it doesn't work either
> because it only promises that the unused expression is not *evaluated*,
> not that it's not "looked at", so it still complains both ways (in the
> constant case that you can't have ({ }) braced groups, and in the non-
> constant case that the _CONST version is bad...
Aaaah right. Seems like we can't avoid introducing a separate macro for
that. I like the idea of your patch anyways!
One note re __BF_CHECK_POW2(): can't we reuse is_power_of_2() anyhow?
Foe example, by deriving the code of the latter into a macro and then
using it in both?
>
> johannes
Thanks,
Olek
next prev parent reply other threads:[~2023-01-18 16:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 13:26 [PATCH] bitfield: add FIELD_PREP_CONST() Johannes Berg
2023-01-18 16:10 ` Alexander Lobakin
2023-01-18 16:22 ` Johannes Berg
2023-01-18 16:49 ` Alexander Lobakin [this message]
2023-01-18 18:03 ` Johannes Berg
2023-01-18 18:21 ` Alexander Lobakin
2023-01-18 19:41 ` Johannes Berg
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=b2c78f45-345b-e3ec-20b1-9d18ee0c9f98@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox