1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

y2038: Replace __clock_gettime with __clock_gettime64

The __clock_gettime internal function is not supporting 64 bit time on
architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g. ARM 32
bit).

The __clock_gettime64 function shall be used instead in the glibc itself as
it supports 64 bit time on those systems.
This patch does not bring any changes to systems with __WORDSIZE == 64 as
for them the __clock_gettime64 is aliased to __clock_gettime (in
./include/time.h).
This commit is contained in:
Lukasz Majewski
2020-03-16 08:31:41 +01:00
parent 5b9b177bf6
commit e9698175b0
9 changed files with 23 additions and 27 deletions

View File

@ -23,15 +23,12 @@
clock_t
clock (void)
{
struct timespec ts;
struct __timespec64 ts;
_Static_assert (CLOCKS_PER_SEC == 1000000,
"CLOCKS_PER_SEC should be 1000000");
/* clock_gettime shouldn't fail here since CLOCK_PROCESS_CPUTIME_ID is
supported since 2.6.12. Check the return value anyway in case the kernel
barfs on us for some reason. */
if (__glibc_unlikely (__clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts) != 0))
if (__glibc_unlikely (__clock_gettime64 (CLOCK_PROCESS_CPUTIME_ID, &ts) != 0))
return (clock_t) -1;
return (ts.tv_sec * CLOCKS_PER_SEC