unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Correct timespec implementation [BZ #26232]
Date: Tue, 14 Jul 2020 14:18:18 +0200	[thread overview]
Message-ID: <87sgdu8f3p.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <CAMe9rOrv-k-2Y3BetUfNnM0Fu+2xoY4DUajtshPFAPB=sL0HVQ@mail.gmail.com> (H. J. Lu's message of "Tue, 14 Jul 2020 05:04:23 -0700")

* H. J. Lu:

> There are
>
> time_t
> support_timespec_ns (struct timespec time)
> {
>   time_t time_ns;
>   if (INT_MULTIPLY_WRAPV(time.tv_sec, TIMESPEC_HZ, &time_ns))
>     return time.tv_sec < 0 ? TYPE_MINIMUM(time_t) : TYPE_MAXIMUM(time_t);
>   if (INT_ADD_WRAPV(time_ns, time.tv_nsec, &time_ns))
>     return time.tv_nsec < 0 ? TYPE_MINIMUM(time_t) : TYPE_MAXIMUM(time_t);
>   return time_ns;
> }
>
> Even if support_timespec_ns is changed to return long long, we still
> may need to keep
>
>  time_t time_ns;
>
> for
>
>    if (INT_MULTIPLY_WRAPV(time.tv_sec, TIMESPEC_HZ, &time_ns))
>
> and
>
>   if (INT_ADD_WRAPV(time_ns, time.tv_nsec, &time_ns))
>
> It looks odd to return long long here.

Why?

You can use the GCC built-ins for checked arithmetic, they support mixed
types.

Thanks,
Florian


  reply	other threads:[~2020-07-14 12:18 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 14:48 [PATCH v2] Fix time/tst-cpuclock1 intermitent failures Lucas A. M. Magalhaes
2020-02-17 16:44 ` Lucas A. M. Magalhaes
2020-02-18 12:44 ` Adhemerval Zanella
2020-02-19 16:42   ` Lucas A. M. Magalhaes
2020-02-19 18:51     ` Adhemerval Zanella
2020-02-20 18:17 ` [PATCH v3] " Lucas A. M. Magalhaes
2020-03-04 19:24   ` Matheus Castanho
2020-03-06 17:31     ` Lucas A. M. Magalhaes
2020-03-10 16:20   ` [PATCH v4] " Lucas A. M. Magalhaes
2020-03-10 16:30     ` Andreas Schwab
2020-03-10 17:45     ` Carlos O'Donell via Libc-alpha
2020-03-23 17:20     ` [PATCH v5] " Lucas A. M. Magalhaes via Libc-alpha
2020-03-23 21:06       ` Carlos O'Donell via Libc-alpha
2020-03-24 19:42         ` Lucas A. M. Magalhaes via Libc-alpha
2020-03-31 18:55           ` Carlos O'Donell via Libc-alpha
2020-03-31 11:34       ` [PATCH v6] " Lucas A. M. Magalhaes via Libc-alpha
2020-03-31 19:02         ` Carlos O'Donell via Libc-alpha
2020-04-03 19:24         ` [PATCH v7] " Lucas A. M. Magalhaes via Libc-alpha
2020-04-03 20:48           ` Carlos O'Donell via Libc-alpha
2020-04-07 13:59           ` [PATCH v8] " Lucas A. M. Magalhaes via Libc-alpha
2020-04-21 17:44             ` [PATCH v9] " Lucas A. M. Magalhaes via Libc-alpha
2020-05-11 17:41               ` Lucas A. M. Magalhaes via Libc-alpha
2020-05-25 11:46                 ` Lucas A. M. Magalhaes via Libc-alpha
2020-06-08 13:58                   ` Lucas A. M. Magalhaes via Libc-alpha
2020-06-08 16:52               ` Carlos O'Donell via Libc-alpha
2020-06-12 15:28               ` [PATCH v10] " Lucas A. M. Magalhaes via Libc-alpha
2020-06-25 17:26                 ` Lucas A. M. Magalhaes via Libc-alpha
2020-07-06 14:15                   ` Lucas A. M. Magalhaes via Libc-alpha
2020-07-07 20:12                 ` Carlos O'Donell via Libc-alpha
2020-07-10 23:07                   ` Tulio Magno Quites Machado Filho
2020-07-11 14:45                     ` H.J. Lu via Libc-alpha
2020-07-11 16:31                       ` H.J. Lu via Libc-alpha
2020-07-13 23:30                         ` [PATCH] Correct timespec implementation [BZ #26232] H.J. Lu via Libc-alpha
2020-07-14  2:35                           ` Carlos O'Donell via Libc-alpha
2020-07-14 11:16                           ` Florian Weimer via Libc-alpha
2020-07-14 11:42                             ` H.J. Lu via Libc-alpha
2020-07-14 12:04                               ` H.J. Lu via Libc-alpha
2020-07-14 12:18                                 ` Florian Weimer via Libc-alpha [this message]
2020-07-14 13:12                                   ` H.J. Lu via Libc-alpha
2020-07-14 13:14                                     ` Florian Weimer via Libc-alpha
2020-07-14 13:17                                       ` H.J. Lu via Libc-alpha
2020-07-15 19:38                                         ` Paul Eggert
2020-07-15 19:44                                           ` H.J. Lu via Libc-alpha
2020-07-14 13:08                               ` Lucas A. M. Magalhaes via Libc-alpha

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=87sgdu8f3p.fsf@oldenburg2.str.redhat.com \
    --to=libc-alpha@sourceware.org \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    /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).