Date: Thu, 03 Dec 2020 20:15:27 +0000 From: "Poul-Henning Kamp" <phk@phk.freebsd.dk> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Cy Schubert <Cy.Schubert@cschubert.com>, freebsd-arch@freebsd.org Subject: Re: struct timex and Linux adjtimex() Message-ID: <25218.1607026527@critter.freebsd.dk> In-Reply-To: <X8lFIX8n7gKMoDk3@kib.kiev.ua> References: <202012030523.0B35NsG7003810@slippy.cwsent.com> <X8i4UIzzH7vxkKvH@kib.kiev.ua> <60532.1606990671@critter.freebsd.dk> <X8i715mJUphnxXEo@kib.kiev.ua> <60612.1606991186@critter.freebsd.dk> <202012031717.0B3HHalx003916@slippy.cwsent.com> <X8lFIX8n7gKMoDk3@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--------
Konstantin Belousov writes:
>
> The value of buf.time is the sum of its two fields, but the
> field buf.time.tv_usec must always be nonnegative. The follow‐
> ing example shows how to normalize a timeval with nanosecond
> resolution.
>
> while (buf.time.tv_usec < 0) {
> buf.time.tv_sec -= 1;
> buf.time.tv_usec += 1000000000;
> }
>
> I do not quite understand the context and internal meaning of the second
> paragraph, though. Kernel should not allow negative tv_usec as the input
> parameter, right ?
Correct.
Minus 10 nanoseconds should be expressed as { .tv_sec = -1; .tv_nsec = 999999990; }
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?25218.1607026527>
