public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] y2038: Introduce struct __timex64 - new internal glibc type
Date: Tue,  5 May 2020 22:58:03 +0000 (GMT)	[thread overview]
Message-ID: <20200505225803.727FD389106F@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dbf8178fdc1cc1c884efd2f5b55703da5adfb051

commit dbf8178fdc1cc1c884efd2f5b55703da5adfb051
Author: Lukasz Majewski <lukma@denx.de>
Date:   Tue Apr 21 19:08:33 2020 +0200

    y2038: Introduce struct __timex64 - new internal glibc type
    
    The introduced glibc's 'internal' struct __timex64 is a copy of Linux kernel's
    struct __kernel_timex (v5.6) introduced for properly handling data for
    clock_adjtime64 syscall.
    As the struct's __kernel_timex size is the same as for archs with
    __WORDSIZE == 64, proper padding and data types conversion (i.e. long to long
    long) had to be added for architectures with __WORDSIZE == 32 &&
    __TIMESIZE != 64.
    
    Moreover, it stores time in struct __timeval64 rather than struct
    timeval, which makes it Y2038-proof.
    
    Build tests:
    ./src/scripts/build-many-glibcs.py glibcs
    
    Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Diff:
---
 sysdeps/unix/sysv/linux/include/sys/timex.h | 46 +++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index 319d566608..c555509c82 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -25,5 +25,51 @@
 
 libc_hidden_proto (__adjtimex)
 
+#  include <struct___timeval64.h>
+/* Local definition of 64 bit time supporting timex struct */
+#  if __TIMESIZE == 64
+#   define __timex64 timex
+#  else
+
+struct __timex64
+{
+  unsigned int modes;          /* mode selector */
+  int :32;                     /* pad */
+  long long int offset;            /* time offset (usec) */
+  long long int freq;              /* frequency offset (scaled ppm) */
+  long long int maxerror;          /* maximum error (usec) */
+  long long int esterror;          /* estimated error (usec) */
+  int status;                  /* clock command/status */
+  int :32;                     /* pad */
+  long long int constant;          /* pll time constant */
+  long long int precision;         /* clock precision (usec) (read only) */
+  long long int tolerance;         /* clock frequency tolerance (ppm) (ro) */
+  struct __timeval64 time;     /* (read only, except for ADJ_SETOFFSET) */
+  long long int tick;              /* (modified) usecs between clock ticks */
+  long long int ppsfreq;           /* pps frequency (scaled ppm) (ro) */
+  long long int jitter;            /* pps jitter (us) (ro) */
+  int shift;                   /* interval duration (s) (shift) (ro) */
+  int :32;                     /* pad */
+  long long int stabil;            /* pps stability (scaled ppm) (ro) */
+  long long int jitcnt;            /* jitter limit exceeded (ro) */
+  long long int calcnt;            /* calibration intervals (ro) */
+  long long int errcnt;            /* calibration errors (ro) */
+  long long int stbcnt;            /* stability limit exceeded (ro) */
+
+  int tai;                     /* TAI offset (ro) */
+
+  int  :32;
+  int  :32;
+  int  :32;
+  int  :32;
+  int  :32;
+  int  :32;
+  int  :32;
+  int  :32;
+  int  :32;
+  int  :32;
+  int  :32;
+};
+#  endif
 # endif /* _ISOMAC */
 #endif /* sys/timex.h */


                 reply	other threads:[~2020-05-05 22:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200505225803.727FD389106F@sourceware.org \
    --to=lukma@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).