This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [[PATCH RFC 2] 02/63] Y2038: add function __difftime64
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Albert ARIBAUD <albert dot aribaud at 3adev dot fr>
- Cc: Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Date: Thu, 3 May 2018 10:53:06 -0700
- Subject: Re: [[PATCH RFC 2] 02/63] Y2038: add function __difftime64
- References: <20180418201819.15952-1-albert.aribaud@3adev.fr> <20180418201819.15952-2-albert.aribaud@3adev.fr> <20180418201819.15952-3-albert.aribaud@3adev.fr> <0a04fc43-9e92-1bbc-843d-049d1026d971@cs.ucla.edu> <20180419150411.4d7ee629@athena> <34e2461c-5da4-181d-d34b-b63c7f89dbf6@cs.ucla.edu> <20180502092209.540847ad@athena> <1a4c2101-130f-79bd-71ff-3393c42c000e@redhat.com> <ccf24625-05e8-85ec-9767-31e90e20c7d0@cs.ucla.edu> <20180503193056.0ded171f@athena>
On 05/03/2018 10:30 AM, Albert ARIBAUD wrote:
the simpler code in difftime.c which 64-bit signed integer
needs is enclosed in run-time conditionals, not compile-time
conditionals
These run-time conditionals are optimized away, and have zero run-time
overhead.
Really, you should use difftime.c and see what it does (look at the
machine code that is generated if you like). You will see that it does
the right thing and generates the same instructions that your copy
would. Similarly for many of the other routines that you incorrectly
think we need to make source-code copies of.
I am choosing not to assume how clever compilers can be, and I consider
that putting a run-time test in some source code will be costlier in
execution time than not putting it there.
This is completely, 100%, backwards. It is routine in high-quality
software nowadays to assume decent optimizing compilers; for example,
that's why we now use functions rather than macros, since simple
functions are routinely inlined. The glibc implementation assumes GCC,
it is not our job to second-guess GCC, and we should not add complexity
to glibc when GCC does a perfectly good job of optimizing simpler code.