From: Marco Elver <elver@google.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com,
masahiroy@kernel.org, ndesaulniers@google.com, joe@perches.com
Subject: Re: [PATCH] genksyms: Ignore module scoped _Static_assert()
Date: Tue, 1 Dec 2020 18:04:21 +0100 [thread overview]
Message-ID: <20201201170421.GA3609680@elver.google.com> (raw)
In-Reply-To: <20201201161414.GA10881@infradead.org>
On Tue, Dec 01, 2020 at 04:14PM +0000, Christoph Hellwig wrote:
> Why not use the kernels own BUILD_BUG_ON instead of this idiom?
BUILD_BUG_ON() was conceived before there was builtin compiler-support
in the form of _Static_assert() (static_assert()), which has several
advantages (compile-time performance, optional message) but most
importantly, that it can be used at module/global scope (which
BUILD_BUG_ON() cannot).
From include/linux/build_bug:
/**
* static_assert - check integer constant expression at build time
*
[...]
*
* Contrary to BUILD_BUG_ON(), static_assert() can be used at global
* scope, but requires the expression to be an integer constant
* expression (i.e., it is not enough that __builtin_constant_p() is
* true for expr).
[...]
.. and there are plenty of global/module scoped users of it already.
Thanks,
-- Marco
next prev parent reply other threads:[~2020-12-01 17:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 15:20 Marco Elver
2020-12-01 16:14 ` Christoph Hellwig
2020-12-01 17:04 ` Marco Elver [this message]
2020-12-01 19:56 ` Nick Desaulniers
2020-12-01 21:01 ` Rasmus Villemoes
2020-12-01 19:59 ` Nick Desaulniers
2020-12-01 20:12 ` Marco Elver
2020-12-04 10:21 ` Marco Elver
2020-12-10 10:35 ` Marco Elver
2020-12-10 13:29 ` Miguel Ojeda
2020-12-10 16:25 ` Marco Elver
2020-12-10 21:48 ` Nick Desaulniers
2020-12-11 5:24 ` Andrew Morton
2020-12-19 12:40 ` Masahiro Yamada
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=20201201170421.GA3609680@elver.google.com \
--to=elver@google.com \
--cc=hch@infradead.org \
--cc=joe@perches.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--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
Powered by JetHome