[PATCH 13/13] string: Add errname_np and errdesc_np

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Jun 2 17:13:57 GMT 2020



On 28/05/2020 09:28, Florian Weimer wrote:
>> diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c
>> index f7a49fbf35..dd078143f2 100644
>> --- a/stdio-common/errlist.c
>> +++ b/stdio-common/errlist.c
>> @@ -28,4 +28,12 @@ const char *const _sys_errlist_internal[] =
>>  
>>  const int _sys_nerr_internal = array_length (_sys_errlist_internal);
>>  
>> +const char *const _sys_errname_internal[] =
>> +  {
>> +/* This file is auto-generated from errlist.def.  */
>> +#include <errlist-name.h>
>> +  };
>> +
>> +const int _sys_nname_internal = array_length (_sys_errname_internal);
>> +
>>  #include <errlist-compat.c>
> 
> There should not be a reason to emit a separate constant for the length
> to the data segment.  And we should eliminate the extra relocations this
> array adds.  But I think we can add these changes later as an
> optimization.
I have removed the constant length variable, however for the extra relocations
from the string array I am not sure if this is really an improvement. The array
is exported as compat symbol (we can't skip its definition) and to fully 
optimize it would require to use a different data structure (such as string
containing all definitions plus a array of indexes) which would require to
duplicate some definition (at least the extra index map).

It might be a gain for architectures that does not have to provide the compat
symbols, but it increases memory usage a bit for the default case (without much
gain in relocation time spent).


More information about the Libc-alpha mailing list