Messages in this thread | | | From | Geert Uytterhoeven <> | Date | Wed, 13 Mar 2019 11:11:08 +0100 | Subject | Re: [PATCH] um: remove uses of variable length arrays |
| |
Hi Bartosz,
On Wed, Mar 13, 2019 at 10:50 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote: > śr., 13 mar 2019 o 10:45 Anton Ivanov > <anton.ivanov@cambridgegreys.com> napisał(a): > > PID can be more than 5 digits nowdays. > > Do we have a macro in the kernel that yields the minimum size of an > array to fit a number? I can't find it. I vagely remember seeing > something like this in systemd tree. If it doesn't exist in the kernel > then maybe we should copy it over.
1 + const_ilog2(n) / log2(10) = 1 + const_ilog2(n) / 3.321928
Using fixed point calculations, that can be approximated as
1 + 19728 * const_ilog2(n) >> 16 1 + 77 * const_ilog2(n) >> 8
(the factors might be one off)
Gr{oetje,eeting}s,
Geert
-- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
| |