[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201201170421.GA3609680@elver.google.com>
Date: Tue, 1 Dec 2020 18:04:21 +0100
From: Marco Elver <elver@...gle.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: linux-kernel@...r.kernel.org, kasan-dev@...glegroups.com,
masahiroy@...nel.org, ndesaulniers@...gle.com, joe@...ches.com
Subject: Re: [PATCH] genksyms: Ignore module scoped _Static_assert()
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
Powered by blists - more mailing lists