diff options
author | Lukasz Majewski <lukma@denx.de> | 2020-03-16 08:31:41 +0100 |
---|---|---|
committer | Lukasz Majewski <lukma@denx.de> | 2020-05-20 16:45:16 +0200 |
commit | e9698175b0b60407db1e89bcf29437ab224bca0b (patch) | |
tree | cb1b6779101327e185e1868b5200cc8a06e98c0b /sysdeps | |
parent | 5b9b177bf62bcdaf42255f88ad9ebf090528c5e1 (diff) | |
download | glibc-e9698175b0b60407db1e89bcf29437ab224bca0b.tar.gz glibc-e9698175b0b60407db1e89bcf29437ab224bca0b.tar.xz glibc-e9698175b0b60407db1e89bcf29437ab224bca0b.zip |
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).
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/generic/hp-timing.h | 4 | ||||
-rw-r--r-- | sysdeps/generic/memusage.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/clock.c | 7 |
4 files changed, 8 insertions, 11 deletions
diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h index e2d7447212..af9d92f7f7 100644 --- a/sysdeps/generic/hp-timing.h +++ b/sysdeps/generic/hp-timing.h @@ -34,8 +34,8 @@ typedef uint64_t hp_timing_t; vDSO symbol. */ #define HP_TIMING_NOW(var) \ ({ \ - struct timespec tv; \ - __clock_gettime (CLOCK_MONOTONIC, &tv); \ + struct __timespec64 tv; \ + __clock_gettime64 (CLOCK_MONOTONIC, &tv); \ (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec); \ }) diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h index a111864b0b..91e56d24de 100644 --- a/sysdeps/generic/memusage.h +++ b/sysdeps/generic/memusage.h @@ -28,9 +28,9 @@ #ifndef GETTIME # define GETTIME(low,high) \ { \ - struct timespec now; \ + struct __timespec64 now; \ uint64_t usecs; \ - clock_gettime (CLOCK_REALTIME, &now); \ + __clock_gettime64 (CLOCK_REALTIME, &now); \ usecs = (uint64_t)now.tv_nsec / 1000 + (uint64_t)now.tv_sec * 1000000; \ low = usecs & 0xffffffff; \ high = usecs >> 32; \ diff --git a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c index 8cf5d303f9..5075ae0444 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c @@ -35,8 +35,8 @@ __gettimeofday_tv32 (struct __timeval32 *restrict tv32, void *restrict tz) if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof (struct timezone)); - struct timespec ts; - __clock_gettime (CLOCK_REALTIME, &ts); + struct __timespec64 ts; + __clock_gettime64 (CLOCK_REALTIME, &ts); *tv32 = valid_timespec_to_timeval32 (ts); return 0; diff --git a/sysdeps/unix/sysv/linux/clock.c b/sysdeps/unix/sysv/linux/clock.c index 24a8df0cf5..157ae8eb3f 100644 --- a/sysdeps/unix/sysv/linux/clock.c +++ b/sysdeps/unix/sysv/linux/clock.c @@ -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 |