* GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) [not found] <1439457109-21833-1-git-send-email-johannes@sipsolutions.net> @ 2015-08-14 8:29 ` Johannes Berg 2015-08-14 9:00 ` Michal Kubecek 0 siblings, 1 reply; 3+ messages in thread From: Johannes Berg @ 2015-08-14 8:29 UTC (permalink / raw) To: linux-wireless, netdev, linux-kernel +linux-kernel > +#define DECLARE_EWMA(name, _factor, _weight)> > > > > \ > +> > struct ewma_##name {> > > > > > > \ > +> > > unsigned long internal;> > > > > > \ > +> > };> > > > > > > > > \ > +> > static inline void ewma_##name##_init(struct ewma_##name *e)> > \ > +> > {> > > > > > > > > \ > +> > > BUILD_BUG_ON(!__builtin_constant_p(_factor));> > > \ > +> > > BUILD_BUG_ON(!__builtin_constant_p(_weight));> > > \ > +> > > BUILD_BUG_ON(!is_power_of_2(_factor));> > > > \ > +> > > BUILD_BUG_ON(!is_power_of_2(_weight));> > > > \ > So this seemed fine to me, but for some reason the compiler is saying the BUILD_BUG_ON(!is_power_of_2(x)) fails, if and only if (!) CONFIG_GCOV_PROFILE_ALL is enabled, which seems to boil down to the compiler option -fprofile-arcs. I'm going to replace this with just the code itself, i.e. /* both must be a power of 2 */ BUILD_BUG_ON(_factor & (_factor - 1)); BUILD_BUG_ON(_weight & (_weight - 1)); but should I have expected this? johannes ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) 2015-08-14 8:29 ` GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) Johannes Berg @ 2015-08-14 9:00 ` Michal Kubecek 2015-08-14 9:05 ` Johannes Berg 0 siblings, 1 reply; 3+ messages in thread From: Michal Kubecek @ 2015-08-14 9:00 UTC (permalink / raw) To: Johannes Berg; +Cc: linux-wireless, netdev, linux-kernel On Fri, Aug 14, 2015 at 10:29:04AM +0200, Johannes Berg wrote: > +linux-kernel > > > +#define DECLARE_EWMA(name, _factor, _weight)> > > > > \ > > +> > struct ewma_##name {> > > > > > > \ > > +> > > unsigned long internal;> > > > > > \ > > +> > };> > > > > > > > > \ > > +> > static inline void ewma_##name##_init(struct ewma_##name *e)> > \ > > +> > {> > > > > > > > > \ > > +> > > BUILD_BUG_ON(!__builtin_constant_p(_factor));> > > \ > > +> > > BUILD_BUG_ON(!__builtin_constant_p(_weight));> > > \ > > +> > > BUILD_BUG_ON(!is_power_of_2(_factor));> > > > \ > > +> > > BUILD_BUG_ON(!is_power_of_2(_weight));> > > > \ > > > > So this seemed fine to me, but for some reason the compiler is saying > the BUILD_BUG_ON(!is_power_of_2(x)) fails, if and only if (!) > CONFIG_GCOV_PROFILE_ALL is enabled, which seems to boil down to the > compiler option -fprofile-arcs. > > I'm going to replace this with just the code itself, i.e. > > /* both must be a power of 2 */ > BUILD_BUG_ON(_factor & (_factor - 1)); > BUILD_BUG_ON(_weight & (_weight - 1)); > > but should I have expected this? It might have something to do with the fact that is_power_of_2() being an inline function, perhaps with this compiler option it translates to something that can't be used in the context BUILD_BUG_ON() uses it in. There is a BUILD_BUG_ON_NOT_POWER_OF_2() macro you could use. Michal Kubecek ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) 2015-08-14 9:00 ` Michal Kubecek @ 2015-08-14 9:05 ` Johannes Berg 0 siblings, 0 replies; 3+ messages in thread From: Johannes Berg @ 2015-08-14 9:05 UTC (permalink / raw) To: Michal Kubecek; +Cc: linux-wireless, netdev, linux-kernel On Fri, 2015-08-14 at 11:00 +0200, Michal Kubecek wrote: > > but should I have expected this? > > It might have something to do with the fact that is_power_of_2() > being an inline function, perhaps with this compiler option it > translates to something that can't be used in the context > BUILD_BUG_ON() uses it in. Evidently, yeah. > There is a BUILD_BUG_ON_NOT_POWER_OF_2() macro you could use. > Good point, I'll do that, thanks. johannes ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-14 9:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1439457109-21833-1-git-send-email-johannes@sipsolutions.net>
2015-08-14 8:29 ` GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) Johannes Berg
2015-08-14 9:00 ` Michal Kubecek
2015-08-14 9:05 ` Johannes Berg
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