[[PATCH RFC 2] 02/63] Y2038: add function __difftime64
Paul Eggert
eggert@cs.ucla.edu
Thu Apr 19 21:36:00 GMT 2018
On 04/19/2018 06:04 AM, Albert ARIBAUD wrote:
> One reason to have a separated implementation is that difftime.c has
> quite complex logic covering many different implementations of time_t
> (signed, unsigned, with padding bits) whereas here we only have signed
> 64-bit integer.
difftime.c is a general implementation that works regardless of the
widths of time_t, int, long, etc. You tried reinventing its wheel but
the reinvention was buggy. Although you could try reinventing its wheel
again, I am afraid there will be another bug with reasonably high
probability. Instead, let's reuse the wheel that we already have; that
will be more likely to be correct, and will be easier to maintain in the
future.
It's not just difftime.c. The same argument applies to mktime, etc. We
shouldn't have two copies of these functions' source code: we should
have just one generic copy, and then compile it once for 64-bit
__time64_t and once for 32-bit time_t. The generic code already works
for both 64-bit and 32-bit time_t, so it should also work for 64-bit
__time64_t.
At bottom I am repeating the comment that Joseph Myers made here:
https://sourceware.org/ml/libc-alpha/2018-04/msg00376.html
More information about the Libc-alpha
mailing list