Thread (9 messages) flat view 9 messages, 5 authors, 2020-02-07

Re: [PATCH bpf] bpf: Improve bucket_log calculation logic

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2020-02-07 21:09:53
Also in: bpf

On Fri, Feb 7, 2020 at 12:13 PM Alexei Starovoitov
[off-list ref] wrote:
In addition to this patch I've tried:
+#define __const_ilog2(n, unique_n) ({                  \
+       typeof(n) unique_n = (n);                       \
Yeah, as you found out, this doesn't work for the case of having
global initializers or things like array sizes.

Which people do do - often nor directly, but through various size macros.

It's annoying, but one of the failures of C is having a nice form of
compile-time constant handling where you can do slightly smarter
arithmetic. The definition of a "const expression" is very very
limited, and hurts us exactly for the array declaration and constant
initializer case.

Oh well.

          Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help