-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: x/sys/unix: add methods to convert between time.Time and unix.PtpClockTime on Linux #70032
Comments
Change https://go.dev/cl/621498 mentions this issue: |
Summary: Pull Request resolved: #418 Avoid the non-upstreamed unix.PtpClockTime.Time(). The related [golang/go#70032](golang/go#70032) is still pending decision. In case of positive outcome we can unland this. Reviewed By: leoleovich Differential Revision: D64901381 fbshipit-source-id: b06c389dff7f0720391bc8dac81e6a346a111a58
This proposal has been added to the active column of the proposals project |
I'm probably missing some background on this. If you convert to a time.Time to do time math and then back to a unix.PtpClockTime, what exactly is the point of unix.PtpClockTime? It seems like any additional information it could carry would be lost. |
I'd still like to understand if there's any danger of lossiness in the conversion to/from |
Bump. It seems like there's no lossiness today, but I don't really understand what the plan is with the "reserved" bits. |
The reserved bits MUST be set to zero in all PTP-related IOCTLs. In fact, the v2 of each of those calls were created to reject non-zero uses of the reserved bytes. In other words, nothing today should be setting those bytes to anything but zero. I hope this clears it up. |
Proposal Details
Recently we have exposed the syscalls and types related to PTP (IEEE 1588) on Linux in the
unix
package.Amongs those is a struct representing time in PTP calls,
unix.PtpClockTime
. Semantically it is very similar to Unix time, differing in underlying type for the nanoseconds field and having a placeholder for future extentions.The proposal is to add the convenience methods to carry conversion between unix.PtpClockTime and time.Time:
This shall allow to use the maths of the standard time package while avoiding
the boilerplate: write
ptpt.Time()
instead oftime.Unix(ptpt.Sec, int64(ptpt.Nsec))
,and
unix.TimeToPtpClockTime(t)
instead ofunix.PtpClockTime{Sec: t.Unix(), Nsec: uint32(t.Nanosecond())}
.As an example of what the boilerplate looks like in real-world code, please see facebook/time#418.
golang/sys#230 implements the proposal.
Thank you for consideration.
The text was updated successfully, but these errors were encountered: