Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1207399 > unrolled thread
| Started by | Johannes Berg <johannes@sipsolutions.net> |
|---|---|
| First post | 2015-08-14 10:30 +0200 |
| Last post | 2015-08-14 11:10 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) Johannes Berg <johannes@sipsolutions.net> - 2015-08-14 10:30 +0200
Re: GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) Michal Kubecek <mkubecek@suse.cz> - 2015-08-14 11:10 +0200
Re: GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) Johannes Berg <johannes@sipsolutions.net> - 2015-08-14 11:10 +0200
| From | Johannes Berg <johannes@sipsolutions.net> |
|---|---|
| Date | 2015-08-14 10:30 +0200 |
| Subject | GCOV_PROFILE_ALL breaks BUILD_BUG_ON(!is_power_of_2(8)) |
| Message-ID | <pXixc-52G-1@gated-at.bofh.it> |
+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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Michal Kubecek <mkubecek@suse.cz> |
|---|---|
| Date | 2015-08-14 11:10 +0200 |
| Message-ID | <pXj9U-618-1@gated-at.bofh.it> |
| In reply to | #1207399 |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Johannes Berg <johannes@sipsolutions.net> |
|---|---|
| Date | 2015-08-14 11:10 +0200 |
| Message-ID | <pXj9U-618-15@gated-at.bofh.it> |
| In reply to | #1207426 |
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web