This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Question about the highly optimized aspects of libc implementation
- From: Florian Weimer <fweimer at redhat dot com>
- To: Will Hawkins <whh8b at virginia dot edu>, libc-help at sourceware dot org
- Date: Thu, 30 Nov 2017 09:36:03 +0100
- Subject: Re: Question about the highly optimized aspects of libc implementation
- Authentication-results: sourceware.org; auth=none
- References: <CAE+MWFsT5vu4yW0zDKgyinZky=2s-i2wzK7N-fnKuQP0kGQ_Bw@mail.gmail.com>
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