diff options
author | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2017-09-08 00:42:05 +0200 |
---|---|---|
committer | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2018-04-18 21:28:44 +0200 |
commit | 2813c9f2431d83b2ca88fab5c67cce8d9f0873c1 (patch) | |
tree | 440af03b494966c22940fc4a93fa3a18a42d4d84 | |
parent | 042fc329cf4d9169b8c46cdf923a4c2c360f0fa5 (diff) | |
download | glibc-2813c9f2431d83b2ca88fab5c67cce8d9f0873c1.tar.gz |
Y2038: add function __adjtime64
-rw-r--r-- | sysdeps/unix/sysv/linux/adjtime.c | 43 | ||||
-rw-r--r-- | time/Versions | 1 | ||||
-rw-r--r-- | time/adjtime.c | 10 |
3 files changed, 54 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c index 6edecb70e8..9e9a4b4176 100644 --- a/sysdeps/unix/sysv/linux/adjtime.c +++ b/sysdeps/unix/sysv/linux/adjtime.c @@ -90,3 +90,46 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv) #ifdef NO_LOCAL_ADJTIME weak_alias (__adjtime, adjtime) #endif + +/* 64-bit time version */ + +extern int __y2038_linux_support; + +int __adjtime64 (const struct __timeval64 *itv, + struct __timeval64 *otv) +{ + struct TIMEX tntx; + + if (itv) + { + struct TIMEVAL tmp; + + /* We will do some check here. */ + tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L; + tmp.tv_usec = itv->tv_usec % 1000000L; + if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC) + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L; + tntx.modes = ADJ_OFFSET_SINGLESHOT; + } + else + tntx.modes = ADJ_OFFSET_SS_READ; + + if (__glibc_unlikely (ADJTIMEX (&tntx) < 0)) + return -1; + + if (otv) + { + if (tntx.offset < 0) + { + otv->tv_usec = -(-tntx.offset % 1000000); + otv->tv_sec = -(-tntx.offset / 1000000); + } + else + { + otv->tv_usec = tntx.offset % 1000000; + otv->tv_sec = tntx.offset / 1000000; + } + } + return 0; +} diff --git a/time/Versions b/time/Versions index 86ced5a7c7..c7e9379243 100644 --- a/time/Versions +++ b/time/Versions @@ -89,5 +89,6 @@ libc { __time64; __stime64; __utimes64; + __adjtime64; } } diff --git a/time/adjtime.c b/time/adjtime.c index 4a972d66cd..800715c016 100644 --- a/time/adjtime.c +++ b/time/adjtime.c @@ -31,3 +31,13 @@ __adjtime (const struct timeval *delta, struct timeval *olddelta) stub_warning (adjtime) weak_alias (__adjtime, adjtime) + +/* 64-bit time version */ + +int +__adjtime64 (const struct __timeval64 *delta, struct __timeval64 *olddelta) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (__adjtime64) |