errno/h_errno
H. Peter Anvin
hpa@zytor.com
Mon Jun 9 23:09:28 GMT 2025
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?
Thanks,
-hpa
More information about the Libc-alpha
mailing list