All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/5] syscalls: Don't pass struct timespec to tst_syscall()
Date: Wed, 20 May 2020 14:35:30 +0530	[thread overview]
Message-ID: <20200520090530.eabgbtpxlmnwbrpm@vireshk-i7> (raw)
In-Reply-To: <CAK8P3a3kS-_ZynTR=o9FVAXEyr9VcAaigOcnG-_Se+wA_+jQoA@mail.gmail.com>

On 20-05-20, 10:47, Arnd Bergmann wrote:
> On Wed, May 20, 2020 at 9:31 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> >
> > On 19-05-20, 14:21, Cyril Hrubis wrote:
> > > So we can as well so that they take the tst_ts structure, then we are
> > > also free to change the way the timestamp is acquired without the need
> > > to change all the callers.
> >
> > I am not sure I understood it all. What do you mean by "also free to change the
> > way the timestamp is acquired"?
> 
> The bug in the current implementation is that the tst_clock_gettime() takes
> the libc type but the argument to the kernel that may expect a different
> type.
> 
> Your patch solves the problem by using the kernel type consistently,
> but the other way to solve it is to keep passing the glibc type and
> instead make tst_clock_gettime() get a timestamp through the low
> level kernel interface using the kernel type and then convert it, like

That can be one way of doing it, but Cyril wasn't suggesting this I believe. He
talked about passing struct tst_ts instead (which is a union of all timespec
types).

> int tst_clock_gettime(clockid_t clk_id, struct timespec *ts)
>  {
>        int ret;
> 
> #ifdef(__NR_clock_gettime64)
>         struct __kernel_timespec newts;
>         ret = tst_syscall(__NR_clock_gettime64, clk_id, &newts);
>         *ts = (struct timespec) { .tv_sec = newts.tv_sec, .tv_nsec =
> newts.tv_nsec };
>         if (ret != -ENOSYS)
>               return ret;
> #endif
> 
> #ifdef __NR_clock_gettime
>         struct __kernel_old_timespec oldts;
>         ret = tst_syscall(__NR_clock_gettime, clk_id, &oldts);
>         *ts = (struct timespec) { .tv_sec = oldts.tv_sec, .tv_nsec =
> oldts.tv_nsec };
>         if (ret != -ENOSYS)
>               return ret;
> #endif
> 
>        /* fallback for prehistoric linux */
>         struct timeval tv;
>         ret = gettimeofday(&tv, NULL);
>         *ts = (struct timespec) { .tv_sec = newts.tv_sec, .tv_usec =
> newts.tv_nsec / 1000};
> 
>         return ret;
> }

This is used only for the internal working of the library and so we may not need
to support all these timespec types TBH and make it complex.

-- 
viresh

  reply	other threads:[~2020-05-20  9:05 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  8:51 [LTP] [PATCH 0/5] syscalls: Remove incorrect usage of libc structures Viresh Kumar
2020-05-19  8:51 ` [LTP] [PATCH 1/5] tst_safe_clocks: Remove safe_clock_adjtime() Viresh Kumar
2020-05-19  8:51 ` [LTP] [PATCH 2/5] syscalls: settimeofday: Use gettimeofday() Viresh Kumar
2020-05-19  9:20   ` Arnd Bergmann
2020-05-19  9:25     ` Viresh Kumar
2020-05-19 10:24       ` Arnd Bergmann
2020-05-19 12:16   ` Cyril Hrubis
2020-05-19 12:47     ` Arnd Bergmann
2020-05-20  7:16     ` Viresh Kumar
2020-05-21 13:16       ` Cyril Hrubis
2020-05-19  8:51 ` [LTP] [PATCH 3/5] syscalls: Don't use tst_syscall() unnecessarily Viresh Kumar
2020-05-19  9:22   ` Arnd Bergmann
2020-05-19  9:28     ` Viresh Kumar
2020-05-19 12:23   ` Cyril Hrubis
2020-05-19 12:41     ` Arnd Bergmann
2020-05-19 12:56       ` Petr Vorel
2020-05-19 13:45       ` Cyril Hrubis
2020-05-20  7:19         ` Viresh Kumar
2020-05-21 14:20           ` Cyril Hrubis
2020-05-21 15:10             ` Arnd Bergmann
2020-05-19  8:51 ` [LTP] [PATCH 4/5] syscalls: Don't pass struct timespec to tst_syscall() Viresh Kumar
2020-05-19 12:21   ` Cyril Hrubis
2020-05-20  7:31     ` Viresh Kumar
2020-05-20  8:47       ` Arnd Bergmann
2020-05-20  9:05         ` Viresh Kumar [this message]
2020-05-20  9:35           ` Arnd Bergmann
2020-05-20  9:39             ` Viresh Kumar
2020-05-20  9:52               ` Arnd Bergmann
2020-05-19  8:51 ` [LTP] [PATCH 5/5] syscalls: Don't pass struct timeval " Viresh Kumar

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=20200520090530.eabgbtpxlmnwbrpm@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.