Re: [PATCH] [media] zl10353: use div_u64 instead of do_div

From: Nicolas Pitre
Date: Fri Feb 12 2016 - 16:39:00 EST


On Fri, 12 Feb 2016, Arnd Bergmann wrote:

> On Friday 12 February 2016 13:21:33 Nicolas Pitre wrote:
> > This is all related to the gcc bug for which I produced a test case
> > here:
> >
> > http://article.gmane.org/gmane.linux.kernel.cross-arch/29801
> >
> > Do you know if this is fixed in recent gcc?
>
> I have a fairly recent gcc, but I also never got around to submit
> it properly.
>
> However, I did stumble over an older patch I did now, which I could
> not remember what it was good for. It does fix the problem, and
> it seems to be a better solution.

WTF?

Hmmm... it apparently doesn't fix it if I apply this change to the gcc
test case.


> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index b5acbb404854..b5ff9881bef8 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -148,7 +148,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
> */
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> #define __trace_if(cond) \
> - if (__builtin_constant_p((cond)) ? !!(cond) : \
> + if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
> ({ \
> int ______r; \
> static struct ftrace_branch_data \
>
>