diff options
author | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2017-08-09 11:03:45 +0200 |
---|---|---|
committer | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2017-08-09 11:03:45 +0200 |
commit | 161bce3da545ed806c269b28dbc8621dd432ae2b (patch) | |
tree | 9071be5e413edf199ed626c673b2d82cae9c6ce7 | |
parent | 644936209e7ca4853f2d522f2f4a76c5b1fd52e3 (diff) | |
download | glibc-161bce3da545ed806c269b28dbc8621dd432ae2b.tar.gz |
Y2038: add Y2038-ready ntp_gettime, ntp_gettimex
-rw-r--r-- | sysdeps/unix/sysv/linux/Versions | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ntp_gettime.c | 16 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ntp_gettimex.c | 22 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sys/timex.h | 15 |
4 files changed, 53 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 3fcd1c252b..5f9a7ab08d 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -178,5 +178,7 @@ libc { GLIBC_Y2038 { __msgctl_t64; + __ntp_gettime_t64; + __ntp_gettimex_t64; } } diff --git a/sysdeps/unix/sysv/linux/ntp_gettime.c b/sysdeps/unix/sysv/linux/ntp_gettime.c index 915b099dc5..ffc0c60aa3 100644 --- a/sysdeps/unix/sysv/linux/ntp_gettime.c +++ b/sysdeps/unix/sysv/linux/ntp_gettime.c @@ -18,6 +18,7 @@ #define ntp_gettime ntp_gettime_redirect #include <sys/timex.h> +#include <include/time.h> #undef ntp_gettime @@ -39,3 +40,18 @@ ntp_gettime (struct ntptimeval *ntv) ntv->esterror = tntx.esterror; return result; } + +int +__ntp_gettime_t64 (struct __ntptimeval_t64 *ntv) +{ + struct timex tntx; + int result; + + tntx.modes = 0; + result = __adjtimex (&tntx); + ntv->time.tv_sec = tntx.time.tv_sec; + ntv->time.tv_usec = tntx.time.tv_usec; + ntv->maxerror = tntx.maxerror; + ntv->esterror = tntx.esterror; + return result; +} diff --git a/sysdeps/unix/sysv/linux/ntp_gettimex.c b/sysdeps/unix/sysv/linux/ntp_gettimex.c index 8ac180163d..5e3fe94396 100644 --- a/sysdeps/unix/sysv/linux/ntp_gettimex.c +++ b/sysdeps/unix/sysv/linux/ntp_gettimex.c @@ -16,6 +16,7 @@ <http://www.gnu.org/licenses/>. */ #include <sys/timex.h> +#include <include/time.h> #ifndef MOD_OFFSET # define modes mode @@ -40,3 +41,24 @@ ntp_gettimex (struct ntptimeval *ntv) ntv->__glibc_reserved4 = 0; return result; } + +int +__ntp_gettimex_t64 (struct __ntptimeval_t64 *ntv) +{ + struct timex tntx; + int result; + + tntx.modes = 0; + result = __adjtimex (&tntx); + ntv->time.tv_sec = tntx.time.tv_sec; + ntv->time.tv_usec = tntx.time.tv_usec; + ntv->maxerror = tntx.maxerror; + ntv->maxerror = tntx.maxerror; + ntv->esterror = tntx.esterror; + ntv->tai = tntx.tai; + ntv->__glibc_reserved1 = 0; + ntv->__glibc_reserved2 = 0; + ntv->__glibc_reserved3 = 0; + ntv->__glibc_reserved4 = 0; + return result; +} diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h index 3f1b013afd..4981d07016 100644 --- a/sysdeps/unix/sysv/linux/sys/timex.h +++ b/sysdeps/unix/sysv/linux/sys/timex.h @@ -57,13 +57,24 @@ __BEGIN_DECLS extern int __adjtimex (struct timex *__ntx) __THROW; extern int adjtimex (struct timex *__ntx) __THROW; -#ifdef __REDIRECT_NTH +#ifndef __USE_TIME_BITS64 +# ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv), ntp_gettimex); -#else +# else extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW; +# define ntp_gettime ntp_gettimex +# endif +#else +# if defined(__REDIRECT) +extern time_t __REDIRECT (ntp_gettimex, (struct ntptimeval *__ntv), + __ntp_gettimex_t64) __THROW; +# else +# define ntp_gettimex __ntp_gettimex_t64 +# endif # define ntp_gettime ntp_gettimex #endif + extern int ntp_adjtime (struct timex *__tntx) __THROW; __END_DECLS |