From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Yury Norov <yury.norov@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org,
Rikard Falkeborn <rikard.falkeborn@gmail.com>,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Subject: [PATCH v4 0/2] add const_true() to simplify GENMASK_INPUT_CHECK()
Date: Thu, 14 Nov 2024 02:18:31 +0900 [thread overview]
Message-ID: <20241113172939.747686-4-mailhol.vincent@wanadoo.fr> (raw)
The first patch introduces a new variant of statically_true() named
const_true() which rely on __is_constexpr() to produce a constant
expression result which can be used in BUILD_BUG_ON_ZERO() and other
macros which expect a constant expression as input.
The second patch applies this newly created const_true() to
GENMASK_INPUT_CHECK().
---
** Changelog **
v3 -> v4:
- rename _statically_true() into const_true().
- fix incorrect subject in the first patch.
- s/Declare/Define in first patch description: macro are defined,
not declared.
- move the godbolt link with the tautology folding examples as a
footnote into the patch description (was after the --- scissors
in v3).
- add more examples of tautologically true expressions in the first
patch description.
- Rewrite the paragraph in the macro comment which compares
statically_true() with const_true() and add code examples
directly into that comment.
Link: https://lore.kernel.org/all/20241112190840.601378-4-mailhol.vincent@wanadoo.fr/
v3 -> v3 RESEND:
- send email using the smtp.wanadoo.fr gateway. Note that this may
appear as smtp.orange.fr which is an alias (both have the same IP).
Link: https://lore.kernel.org/all/20241112140454.518823-4-mailhol.vincent@wanadoo.fr/
v2 -> v3:
- split the single patch into a series of two patches.
- add explanation of why _statically_true() is needed in addition
to the existing statically_true(). Explain the pros and cons of
each.
- use __builtin_choose_expr() in _statically_true(). The
_statically_true() of the v2 works perfectly fine when used in
conjunction with BUILD_BUG_ON_ZERO() but fails if used, for
example, in arrays or in static_assert().
Link: https://lore.kernel.org/all/20241111164743.339117-2-mailhol.vincent@wanadoo.fr/
v1 -> v2:
- introduce _statically_true(), taking inspiration from
statically_true() as introduced in commit 22f546873149 ("minmax:
improve macro expansion and type checking").
Link: https://lore.kernel.org/all/20240609073513.256179-1-mailhol.vincent@wanadoo.fr/
Vincent Mailhol (2):
compiler.h: add const_true()
linux/bits.h: simplify GENMASK_INPUT_CHECK()
include/linux/bits.h | 5 ++---
include/linux/compiler.h | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
--
2.45.2
next reply other threads:[~2024-11-13 17:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-13 17:18 Vincent Mailhol [this message]
2024-11-13 17:18 ` [PATCH v4 1/2] compiler.h: add const_true() Vincent Mailhol
2024-11-13 18:53 ` Yury Norov
2024-12-30 18:32 ` Yury Norov
2024-12-31 4:58 ` Vincent Mailhol
2024-11-17 17:42 ` David Laight
2024-11-17 18:00 ` Linus Torvalds
2024-11-17 19:02 ` Linus Torvalds
2024-11-17 19:05 ` David Laight
2024-11-17 19:09 ` Linus Torvalds
2024-11-17 19:23 ` David Laight
2024-11-17 20:12 ` Linus Torvalds
2024-11-17 22:38 ` David Laight
2024-11-17 22:58 ` Linus Torvalds
2024-11-18 3:22 ` Vincent Mailhol
2024-11-18 9:27 ` David Laight
2024-11-18 17:09 ` Linus Torvalds
2024-11-13 17:18 ` [PATCH v4 2/2] linux/bits.h: simplify GENMASK_INPUT_CHECK() Vincent Mailhol
2024-11-17 17:24 ` David Laight
2024-11-17 19:45 ` David Laight
2024-11-18 1:14 ` Vincent Mailhol
2024-11-18 1:12 ` Vincent Mailhol
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=20241113172939.747686-4-mailhol.vincent@wanadoo.fr \
--to=mailhol.vincent@wanadoo.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=luc.vanoostenryck@gmail.com \
--cc=rikard.falkeborn@gmail.com \
--cc=torvalds@linux-foundation.org \
--cc=yury.norov@gmail.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