[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdXC5QffaOj479j3WCt5_GH2jeQnGrPoCrRPoFkHmFeDfw@mail.gmail.com>
Date: Wed, 13 Mar 2019 11:11:08 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Anton Ivanov <anton.ivanov@...bridgegreys.com>,
Jeff Dike <jdike@...toit.com>,
Richard Weinberger <richard@....at>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
linux-um@...ts.infradead.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] um: remove uses of variable length arrays
Hi Bartosz,
On Wed, Mar 13, 2019 at 10:50 AM Bartosz Golaszewski <brgl@...ev.pl> wrote:
> śr., 13 mar 2019 o 10:45 Anton Ivanov
> <anton.ivanov@...bridgegreys.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@...ux-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
Powered by blists - more mailing lists