diff options
author | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2017-09-08 00:42:15 +0200 |
---|---|---|
committer | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2018-04-18 21:28:45 +0200 |
commit | 7d9864c8f953bf47cf1b1aab40d8185624c72791 (patch) | |
tree | fc51dffe8151cc80054d42941de6ebb52bd03539 | |
parent | b3bc67807767847630d382a0c129b0f21b08e06b (diff) | |
download | glibc-7d9864c8f953bf47cf1b1aab40d8185624c72791.tar.gz |
Y2038: add function __adjtimex64 (and __ntp_adjtime64)
-rw-r--r-- | sysdeps/unix/sysv/linux/adjtime.c | 81 | ||||
-rw-r--r-- | time/Versions | 1 |
2 files changed, 82 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c index 9e9a4b4176..4dd73ecf5d 100644 --- a/sysdeps/unix/sysv/linux/adjtime.c +++ b/sysdeps/unix/sysv/linux/adjtime.c @@ -19,6 +19,7 @@ #include <limits.h> #include <sys/time.h> #include <sys/timex.h> +#include <include/time.h> #define MAX_SEC (INT_MAX / 1000000L - 2) #define MIN_SEC (INT_MIN / 1000000L + 2) @@ -133,3 +134,83 @@ int __adjtime64 (const struct __timeval64 *itv, } return 0; } + +int +__adjtimex64(struct __timex64 *tx) +{ + struct timex tx32; + + if (__y2038_linux_support) + { + /* TODO: implement with a 64-bit time syscall */ + } + + if (tx == NULL) + { + __set_errno (EFAULT); + return -1; + } + + if ((tx->modes & ADJ_SETOFFSET) != 0 && tx->time.tv_sec > INT_MAX) + { + __set_errno (EOVERFLOW); + return -1; + } + + /* Implement with existing 32-bit time syscall */ + + /* Just copy everything */ + tx32.modes = tx->modes; + tx32.offset = tx->offset; + tx32.freq = tx->freq; + tx32.maxerror = tx->maxerror; + tx32.esterror = tx->esterror; + tx32.status = tx->status; + tx32.constant = tx->constant; + tx32.precision = tx->precision; + tx32.tolerance = tx->tolerance; + tx32.time.tv_sec = tx->time.tv_sec; + tx32.time.tv_usec = tx->time.tv_usec; + tx32.tick = tx->tick; + tx32.ppsfreq = tx->ppsfreq; + tx32.jitter = tx->jitter; + tx32.shift = tx->shift; + tx32.stabil = tx->stabil; + tx32.jitcnt = tx->jitcnt; + tx32.calcnt = tx->calcnt; + tx32.errcnt = tx->errcnt; + tx32.stbcnt = tx->stbcnt; + + tx32.tai = tx->tai; + /* WARNING -- anonymous fields after TAI are not copied. */ + + int result = ADJTIMEX(&tx32); + + if (result == 0) + { + /* Just copy back everything */ + tx->modes = tx32.modes; + tx->offset = tx32.offset; + tx->freq = tx32.freq; + tx->maxerror = tx32.maxerror; + tx->esterror = tx32.esterror; + tx->status = tx32.status; + tx->constant = tx32.constant; + tx->precision = tx32.precision; + tx->tolerance = tx32.tolerance; + tx->time.tv_sec = tx32.time.tv_sec; + tx->time.tv_usec = tx32.time.tv_usec; + tx->tick = tx32.tick; + tx->ppsfreq = tx32.ppsfreq; + tx->jitter = tx32.jitter; + tx->shift = tx32.shift; + tx->stabil = tx32.stabil; + tx->jitcnt = tx32.jitcnt; + tx->calcnt = tx32.calcnt; + tx->errcnt = tx32.errcnt; + tx->stbcnt = tx32.stbcnt; + } + + return result; +} +weak_alias (__adjtimex64, __ntp_adjtime64); diff --git a/time/Versions b/time/Versions index 4249655d70..12475d7480 100644 --- a/time/Versions +++ b/time/Versions @@ -92,5 +92,6 @@ libc { __adjtime64; __getitimer64; __setitimer64; + __adjtimex64; } } |