[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <02874ECE860811409154E81DA85FBB58579A1F19@ORSMSX115.amr.corp.intel.com>
Date: Wed, 17 Feb 2016 20:37:26 +0000
From: "Keller, Jacob E" <jacob.e.keller@...el.com>
To: Krzysztof Kozlowski <k.kozlowski@...sung.com>,
Sangbeom Kim <sbkim73@...sung.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-samsung-soc@...r.kernel.org"
<linux-samsung-soc@...r.kernel.org>
CC: Arnd Bergmann <arnd@...db.de>
Subject: RE: [RFT] regulator: s2mps11: Simplify expression used in
BUILD_BUG_ON for some of preprocessors
Hi,
> -----Original Message-----
> From: linux-kernel-owner@...r.kernel.org [mailto:linux-kernel-
> owner@...r.kernel.org] On Behalf Of Krzysztof Kozlowski
> Sent: Wednesday, February 17, 2016 12:11 AM
> To: Sangbeom Kim <sbkim73@...sung.com>; Krzysztof Kozlowski
> <k.kozlowski@...sung.com>; Liam Girdwood <lgirdwood@...il.com>;
> Mark Brown <broonie@...nel.org>; linux-kernel@...r.kernel.org; linux-
> samsung-soc@...r.kernel.org
> Cc: Arnd Bergmann <arnd@...db.de>
> Subject: [RFT] regulator: s2mps11: Simplify expression used in
> BUILD_BUG_ON for some of preprocessors
>
> Apparently some preprocessors have problems with interpreting
> BUILD_BUG_ON such as:
> var = ARRAY_SIZE(s2mps15_regulators);
> BUILD_BUG_ON(S2MPS_REGULATOR_MAX < var);
> so let make it more obvious for them.
>
Doesn't have much to do with the preprocessor, but rather exactly how the compiler optimizes the variable. Some kernel configurations also impact this, and it heavily depends on whether the compiler actually optimizes away the variable. BUILD_BUG_ON may work a lot of the time, depending heavily on the compiler.
BUILD_BUG_ON only works for constant expressions, so it is safer to put the value in directly, because using a variable will only work if the compiler optimizes the use of a variable away entirely. In this case it is somewhat surprising that it doesn't, but would depend on what compiler version and what kernel build rules you were using. For example allmodconfig ends up selecting everything yes if it's not a module for kernel build options and results in some BUILD_BUG_ON failures because of that)
Thanks,
Jake
Powered by blists - more mailing lists