diff options
author | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2018-12-20 22:14:08 +0100 |
---|---|---|
committer | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2018-12-20 22:16:55 +0100 |
commit | ac253355baf6ce73a92c4f4d94a32b65859fc634 (patch) | |
tree | 729d6687bb85fce009bab970220df57d2d438a33 /include/time.h | |
parent | ab4169313cdb15d688242609aef879fc5121356e (diff) | |
download | glibc-ac253355baf6ce73a92c4f4d94a32b65859fc634.zip glibc-ac253355baf6ce73a92c4f4d94a32b65859fc634.tar.gz glibc-ac253355baf6ce73a92c4f4d94a32b65859fc634.tar.bz2 |
Y2038: make __difftime compatible with 64-bit time
Provide a 64-bit-time version of __difftime (but do not assume
__time64_t is a signed int so that Gnulib can reuse the code)
and make the 32-bit version a wrapper of it.
Current difftime expects two time_t arguments and returns a
double. To preserve source-code compatibility, its 64-bit-time
equivalent expects two __time64_t arguments but still returns
a double.
This patch was tested by running 'make check' on branch
master then applying this patch and its two predecessors and
running 'make check' again, and checking that both 'make check'
yield identical results. This was done on x86_64-linux-gnu and
i686-linux-gnu.
This patch was also functionally tested with an ad hoc userland
C program which checks the result of difftime for various pairs
of 32-bit and, for 64-bit builds, of 64-bit time_t values too.
The program was built and run against a glibc with and without
the patch, and the results compared to ensure the patch does
not change the behavior of difftime.
* include/time.h (__difftime64): Add.
* time/difftime.c (subtract): convert to 64-bit time.
* time/difftime.c (__difftime64): Add.
* time/difftime.c (__difftime): Wrap around __difftime64.
Diffstat (limited to 'include/time.h')
-rw-r--r-- | include/time.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/time.h b/include/time.h index a10a59a..f935e9d 100644 --- a/include/time.h +++ b/include/time.h @@ -141,6 +141,13 @@ extern char * __strptime_internal (const char *rp, const char *fmt, struct tm *tm, void *statep, locale_t locparam) attribute_hidden; +#if __TIMESIZE == 64 +# define __difftime64 __difftime +#else +extern double __difftime64 (__time64_t time1, __time64_t time0); +libc_hidden_proto (__difftime64) +#endif + extern double __difftime (time_t time1, time_t time0); |