RE: [PATCH v1 1/2] vsprintf: introduce %dE for error constants
From: David Laight
Date: Fri Aug 30 2019 - 09:21:22 EST
From: Enrico Weigelt, metux IT consult
> Sent: 26 August 2019 14:29
> On 25.08.19 01:37, Uwe Kleine-KÃÂnig wrote:
>
> Hi,
>
> > +static noinline_for_stack > +char *errstr(char *buf, char *end, unsigned long long num,> +
> struct printf_spec spec)> +{
> #1: why not putting that into some separate strerror() lib function ?
> This is something I've been looking for quite some time (actually
> already hacked it up somewhere, sometime, but forgotten ...)
>
> #2: why not just having a big case statement and leave the actual lookup
> logic to the compiler ? IMHO, could be written in a very compact way
> by some macro magic
And generate an enormous amount of code and long chains of mispredicted branches.
Is it also worth looking at how long the strings are.
If they can be truncated to 16 bytes then char[][16] will generate
much better code than the array of pointers.
OTOH I'm not really sure it is all a good idea.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)