errno/h_errno
Andrew Pinski
pinskia@gmail.com
Mon Jun 9 23:28:31 GMT 2025
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
>
More information about the Libc-alpha
mailing list