Yup, I'm observing this on 32-bit system. Even though my kernel
supports 64-bit time_t, nanoseconds are still signed long int there...

Thanks,
Pawel

wt., 10 paź 2023 o 12:42 Miroslav Lichvar <mlich...@redhat.com> napisał(a):
>
> On Tue, Oct 10, 2023 at 12:29:22PM +0200, Paweł Modrzejewski wrote:
> > Make it possible to set timeout values bigger than 2.147 sec
> > and print error message in case port_set_sync_rx_tmo() fails.
>
> I think this limitation was specific to 32-bit systems that don't use
> 64-bit time_t.
>
> > --- a/port.c
> > +++ b/port.c
> > @@ -245,12 +245,9 @@ int set_tmo_log(int fd, unsigned int scale, int 
> > log_seconds)
> >               for (i = 1, ns = scale * 500000000ULL; i < log_seconds; i++) {
> >                       ns >>= 1;
> >               }
> > -             tmo.it_value.tv_nsec = ns;
> >
> > -             while (tmo.it_value.tv_nsec >= NS_PER_SEC) {
> > -                     tmo.it_value.tv_nsec -= NS_PER_SEC;
> > -                     tmo.it_value.tv_sec++;
> > -             }
> > +             tmo.it_value.tv_sec = ns / NS_PER_SEC;
> > +             tmo.it_value.tv_nsec = ns % NS_PER_SEC;
>
> The fix looks good to me. Replacing the repeated subtraction with
> division also fixes a potential slowdown with large scales.
>
> --
> Miroslav Lichvar
>


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to