Question about the highly optimized aspects of libc implementation

Florian Weimer fweimer@redhat.com
Thu Nov 30 08:36:00 GMT 2017


On 11/30/2017 07:47 AM, Will Hawkins wrote:
> I've been digging through the glibc implementation and looking for
> examples of where compiler directives or hand-written assembly have
> been used to improve performance at the "expense" of standards or
> conventions.

The fcntl implementation calls va_arg on a variadic argument which might 
not actually exist.  The syscall function does something similar (but it 
is actually implemented in machine code, so it's less of a problem).

The NSS internals in general and getaddrinfo in particular call 
functions through a mis-matching function pointer (with an additional 
argument added, or with a void * argument where the function is defined 
with a concrete function pointer).

Calling functions such as getpwuid_r with a pointer which has not been 
allocated on the heap (or reusing an existing allocation for a second 
call) is probably not quite valid C due to aliasing violations.

A lot of the code which manipulates struct 
sockaddr/sockaddr_in/sockaddr_in6 objects does not make the additional 
copies which are needed to avoid aliasing violations.

Do you need more?  I can probably go on for quite some time.

Thanks,
Florian



More information about the Libc-help mailing list