public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: Lukasz Majewski <lukma@denx.de>
Cc: Joseph Myers <joseph@codesourcery.com>,
	 Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	Alistair Francis <alistair.francis@wdc.com>,
	 GNU C Library <libc-alpha@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>,
	Andreas Schwab <schwab@suse.de>
Subject: Re: [PATCH 03/10] y2038: Provide conversion helpers for struct __timex64
Date: Mon, 27 Apr 2020 08:22:54 -0700	[thread overview]
Message-ID: <CAKmqyKPC1LqeNBwyiUOr4XTqZ5Ry31hYa_bTa5EzL4GEzwJeAA@mail.gmail.com> (raw)
In-Reply-To: <20200426133110.5312-4-lukma@denx.de>

On Sun, Apr 26, 2020 at 6:31 AM Lukasz Majewski <lukma@denx.de> wrote:
>
> Those functions allow easy conversion between Y2038 safe, glibc internal
> struct __timex64 and struct timex.
>
> Those functions are put in Linux specific sys/timex.h file, as putting
> them into glibc's local include/time.h would cause build break on HURD as
> it doesn't support struct timex related syscalls.
>
> Build tests:
> ./src/scripts/build-many-glibcs.py glibcs

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  sysdeps/unix/sysv/linux/include/sys/timex.h | 61 +++++++++++++++++++++
>  1 file changed, 61 insertions(+)
>
> diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
> index f25081639b..bab6b28920 100644
> --- a/sysdeps/unix/sysv/linux/include/sys/timex.h
> +++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
> @@ -25,6 +25,7 @@
>
>  libc_hidden_proto (__adjtimex)
>
> +#  include <time.h>
>  #  include <struct___timeval64.h>
>  /* Local definition of 64 bit time supporting timex struct */
>  #  if __TIMESIZE == 64
> @@ -63,5 +64,65 @@ struct __timex64
>    int  :32; int  :32; int  :32;
>  };
>  #  endif
> +
> +/* Convert a known valid struct timex into a struct __timex64.  */
> +static inline struct __timex64
> +valid_timex_to_timex64 (const struct timex tx)
> +{
> +  struct __timex64 tx64;
> +
> +  tx64.modes = tx.modes;
> +  tx64.offset = tx.offset;
> +  tx64.freq = tx.freq;
> +  tx64.maxerror = tx.maxerror;
> +  tx64.esterror = tx.esterror;
> +  tx64.status = tx.status;
> +  tx64.constant = tx.constant;
> +  tx64.precision = tx.precision;
> +  tx64.tolerance = tx.tolerance;
> +  tx64.time = valid_timeval_to_timeval64 (tx.time);
> +  tx64.tick = tx.tick;
> +  tx64.ppsfreq = tx.ppsfreq;
> +  tx64.jitter = tx.jitter;
> +  tx64.shift = tx.shift;
> +  tx64.stabil = tx.stabil;
> +  tx64.jitcnt = tx.jitcnt;
> +  tx64.calcnt = tx.calcnt;
> +  tx64.errcnt = tx.errcnt;
> +  tx64.stbcnt = tx.stbcnt;
> +  tx64.tai = tx.tai;
> +
> +  return tx64;
> +}
> +
> +/* Convert a known valid struct __timex64 into a struct timex.  */
> +static inline struct timex
> +valid_timex64_to_timex (const struct __timex64 tx64)
> +{
> +  struct timex tx;
> +
> +  tx.modes = tx64.modes;
> +  tx.offset = tx64.offset;
> +  tx.freq = tx64.freq;
> +  tx.maxerror = tx64.maxerror;
> +  tx.esterror = tx64.esterror;
> +  tx.status = tx64.status;
> +  tx.constant = tx64.constant;
> +  tx.precision = tx64.precision;
> +  tx.tolerance = tx64.tolerance;
> +  tx.time = valid_timeval64_to_timeval (tx64.time);
> +  tx.tick = tx64.tick;
> +  tx.ppsfreq = tx64.ppsfreq;
> +  tx.jitter = tx64.jitter;
> +  tx.shift = tx64.shift;
> +  tx.stabil = tx64.stabil;
> +  tx.jitcnt = tx64.jitcnt;
> +  tx.calcnt = tx64.calcnt;
> +  tx.errcnt = tx64.errcnt;
> +  tx.stbcnt = tx64.stbcnt;
> +  tx.tai = tx64.tai;
> +
> +  return tx;
> +}
>  # endif /* _ISOMAC */
>  #endif /* sys/timex.h */
> --
> 2.20.1
>

  reply	other threads:[~2020-04-27 15:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26 13:31 [PATCH 00/10] y2038: Convert clock_adjtime related syscalls to support 64 bit time Lukasz Majewski
2020-04-26 13:31 ` [PATCH 01/10] y2038: include: Move struct __timeval64 definition to a separate file Lukasz Majewski
2020-04-27 15:18   ` Alistair Francis
2020-04-28 14:24   ` Adhemerval Zanella
2020-04-26 13:31 ` [PATCH 02/10] y2038: Introduce struct __timex64 - new internal glibc type Lukasz Majewski
2020-04-27 15:22   ` Alistair Francis
2020-04-28 14:34   ` Adhemerval Zanella
2020-04-29 21:45     ` Lukasz Majewski
2020-04-26 13:31 ` [PATCH 03/10] y2038: Provide conversion helpers for struct __timex64 Lukasz Majewski
2020-04-27 15:22   ` Alistair Francis [this message]
2020-04-28 15:56   ` Adhemerval Zanella
2020-04-26 13:31 ` [PATCH 04/10] y2038: linux: Provide __clock_adjtime64 implementation Lukasz Majewski
2020-04-27 22:12   ` Alistair Francis
2020-04-28 17:00   ` Adhemerval Zanella
2020-04-29 21:43     ` Lukasz Majewski
2020-04-26 13:31 ` [PATCH 05/10] y2038: linux: Provide ___adjtimex64 implementation Lukasz Majewski
2020-04-27 22:12   ` Alistair Francis
2020-04-28 17:14   ` Adhemerval Zanella
2020-04-26 13:31 ` [PATCH 06/10] y2038: linux: Provide __adjtime64 implementation Lukasz Majewski
2020-04-27 22:14   ` Alistair Francis
2020-04-28 18:33   ` Adhemerval Zanella
2020-04-26 13:31 ` [PATCH 07/10] y2038: Introduce struct __ntptimeval64 - new internal glibc type Lukasz Majewski
2020-04-28 18:41   ` Adhemerval Zanella
2020-04-29 21:28     ` Lukasz Majewski
2020-05-07 18:32       ` Lukasz Majewski
2020-04-26 13:31 ` [PATCH 08/10] y2038: Provide conversion helpers for struct __ntptimeval64 Lukasz Majewski
2020-04-26 13:31 ` [PATCH 09/10] y2038: linux: Provide __ntp_gettime64 implementation Lukasz Majewski
2020-04-26 13:31 ` [PATCH 10/10] y2038: linux: Provide __ntp_gettimex64 implementation Lukasz Majewski

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=CAKmqyKPC1LqeNBwyiUOr4XTqZ5Ry31hYa_bTa5EzL4GEzwJeAA@mail.gmail.com \
    --to=alistair23@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=lukma@denx.de \
    --cc=schwab@suse.de \
    /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).