Date: Thu, 03 Dec 2020 14:58:52 -0800 From: Cy Schubert <Cy.Schubert@cschubert.com> To: "Poul-Henning Kamp" <phk@phk.freebsd.dk> Cc: Cy Schubert <Cy.Schubert@cschubert.com>, Ian Lepore <ian@freebsd.org>, freebsd-arch@freebsd.org Subject: Re: struct timex and Linux adjtimex() Message-ID: <202012032258.0B3MwqVQ004875@slippy.cwsent.com> In-Reply-To: <25989.1607033614@critter.freebsd.dk> References: <202012030523.0B35NsG7003810@slippy.cwsent.com> <4086.1606982335@critter.freebsd.dk> <5e0db735b29f1ece02521871b2cd392c3467101d.camel@freebsd.org> <25487.1607029223@critter.freebsd.dk> <202012032203.0B3M3VJx004269@slippy.cwsent.com> <25989.1607033614@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <25989.1607033614@critter.freebsd.dk>, "Poul-Henning Kamp"
writes:
> --------
> Cy Schubert writes:
>
> > I will go back
> > with my initial proposal of a timespec add/subtract syscall takes a
> > timespec as input increments or decrements the clock by the timespec and
> > returns a timespec with the time.
>
> I would be tempted by the clock_settime(2) "clock_id" argument.
>
> The functionality required has a LOT more commonality with
> clock_settime(2) than with ntp_adjtime(2), and absconding with a
> couple of the top bits of clock_id for "CLOCK_ADD_ADJUSTMENT" and
> "CLOCK_SUB_ADJUSTMENT" would be be a pretty clean solution.
Correct. My initial proposal was:
+.Fn clock_updtime "clockid_t clock_id" "const struct timespec *itp"
"struct timespec *otp"
Briefly it does this:
+int
+kern_clock_updtime(struct thread *td, clockid_t clock_id,
+ const struct timespec *its, struct timespec *ots)
+{
+ struct timespec ats;
+ int error;
+
+ if ((error = kern_clock_gettime(td, clock_id, &ats)) != 0)
+ return (error);
+
+ timespecadd(its, &ats, &ats);
+
+ if ((error = kern_clock_settime(td, clock_id, &ats)) != 0)
+ return (error);
+
+ return(kern_clock_gettime(td, clock_id, ots));
+}
I can prepare a review if you want. I haven't touched the man page nor any
tests yet.
It's affected by kib@'s https://reviews.freebsd.org/D27471, as conflicts
will result. I'll wait until that's committed before continuing work on it,
assuming this is the direction we want to go.
--
Cheers,
Cy Schubert <Cy.Schubert@cschubert.com>
FreeBSD UNIX: <cy@FreeBSD.org> Web: https://FreeBSD.org
NTP: <cy@nwtime.org> Web: https://nwtime.org
The need of the many outweighs the greed of the few.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012032258.0B3MwqVQ004875>
