linux-sg2042/tools/include/linux
Linus Torvalds 474c90156c give up on gcc ilog2() constant optimizations
gcc-7 has an "optimization" pass that completely screws up, and
generates the code expansion for the (impossible) case of calling
ilog2() with a zero constant, even when the code gcc compiles does not
actually have a zero constant.

And we try to generate a compile-time error for anybody doing ilog2() on
a constant where that doesn't make sense (be it zero or negative).  So
now gcc7 will fail the build due to our sanity checking, because it
created that constant-zero case that didn't actually exist in the source
code.

There's a whole long discussion on the kernel mailing about how to work
around this gcc bug.  The gcc people themselevs have discussed their
"feature" in

   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785

but it's all water under the bridge, because while it looked at one
point like it would be solved by the time gcc7 was released, that was
not to be.

So now we have to deal with this compiler braindamage.

And the only simple approach seems to be to just delete the code that
tries to warn about bad uses of ilog2().

So now "ilog2()" will just return 0 not just for the value 1, but for
any non-positive value too.

It's not like I can recall anybody having ever actually tried to use
this function on any invalid value, but maybe the sanity check just
meant that such code never made it out in public.

Reported-by: Laura Abbott <labbott@redhat.com>
Cc: John Stultz <john.stultz@linaro.org>,
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-03-02 12:17:22 -08:00
..
atomic.h tools include: Add basic atomic.h implementation from the kernel sources 2015-05-08 16:11:05 -03:00
bitmap.h radix tree test suite: Remove duplicate bitops code 2017-01-27 21:29:39 -05:00
bitops.h radix tree test suite: Remove duplicate bitops code 2017-01-27 21:29:39 -05:00
compiler-gcc.h tools include: Introduce linux/compiler-gcc.h 2017-02-13 14:29:29 -03:00
compiler.h Merge branch 'idr-4.11' of git://git.infradead.org/users/willy/linux-dax 2017-02-28 20:29:41 -08:00
coresight-pmu.h tools: Copy coresight-pmu.h header file needed by perf tools 2016-08-23 15:37:33 -03:00
err.h tools: Fix shadowed declaration in err.h 2015-09-30 18:34:22 -03:00
export.h tools: Restore export.h 2015-08-25 09:44:22 +02:00
filter.h bpf: add initial suite for selftests 2016-10-18 11:35:55 -04:00
hash.h tools: Copy linux/{hash,poison}.h and check for drift 2016-07-18 18:41:50 -03:00
hashtable.h tools: Copy hashtable.h into tools directory 2016-03-09 10:48:09 +01:00
kernel.h perf tools: Uninline scnprintf() and vscnprint() 2016-07-12 15:20:24 -03:00
list.h tools: Make list.h self-sufficient 2016-01-12 12:42:07 -03:00
log2.h give up on gcc ilog2() constant optimizations 2017-03-02 12:17:22 -08:00
poison.h tools: Copy linux/{hash,poison}.h and check for drift 2016-07-18 18:41:50 -03:00
rbtree.h tools: Move rbtree.h from tools/perf/ 2015-07-05 22:54:01 -03:00
rbtree_augmented.h tools: Copy rbtree_augmented.h from the kernel 2015-07-05 22:59:05 -03:00
spinlock.h radix tree test suite: Remove types.h 2017-02-13 16:09:41 -05:00
string.h tools lib: Reinstate strlcpy() header guard with __UCLIBC__ 2016-08-18 16:19:13 -03:00
stringify.h tools include: Copy linux/stringify.h from the kernel 2016-03-23 15:14:27 -03:00
time64.h tools: Introduce tools/include/linux/time64.h for *SEC_PER_*SEC macros 2016-08-23 15:37:33 -03:00
types.h tools: enable endian checks for all sparse builds 2016-12-16 00:13:39 +02:00