errno/h_errno

H. Peter Anvin hpa@zytor.com
Tue Jun 10 03:51:25 GMT 2025


On June 9, 2025 4:28:31 PM PDT, Andrew Pinski <pinskia@gmail.com> wrote:
>On Mon, Jun 9, 2025 at 4:10 PM H. Peter Anvin <hpa@zytor.com> wrote:
>>
>> Hi,
>>
>> I'm wondering: is there any reason whatsoever why not to change the
>> definition of errno/h_errno to:
>>
>> __thread int errno __attribute__((tls_model("initial-exec")));
>>
>> ... to bypass a rather unnecessary function call? After all, errno gets
>> accessed *all over the place*, and there is no reason why other modules
>> should not be able to make use of this. As far as I understand, the
>> above should result, for PIC code, in a GOTTPOFF relocation, and a GOT
>> entry filled in by the dynamic linker.
>>
>> The functions __[h_]errno_location can of course remain for
>> compatibility reasons.
>>
>> This would seem to be a trivial optimization, which would even be
>> backwards compatible.
>>
>> Am I missing something fundamental?
>
>See the previous thread about this:
>https://inbox.sourceware.org/libc-alpha/CAMe9rOrb8XPsTUKHMw7F-+iy7D=UH=5XP_K06wDAwka+RRDCgw@mail.gmail.com/
>
>Thanks,
>Andrew
>
>>
>> Thanks,
>>
>>         -hpa
>>
>

Ok, I grok that back in 2016 the tools might not have been ready yet, but in 2025?


More information about the Libc-alpha mailing list