From cb65c8d58ac76abdaa6d14cc0742ca23d00ff524 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Mon, 12 Oct 2020 10:51:34 -0400 Subject: syscall: switch go:generate directives back to mksyscall_windows.go Adjust mksyscall_windows.go to activate module mode and set -mod=readonly, and to suppress its own deprecation warning when run from within GOROOT/src. We can't vendor the mkwinsyscall tool in to the std module directly, because std-vendored dependencies (unlike the dependencies of all other modules) turn into actual, distinct packages in 'std' when viewed from outside the 'std' module. We don't want to introduce a binary in the 'std' meta-pattern, but we also don't particularly want to add more special-cases to the 'go' command right now when we have an existing wrapper program that can do the job. I also regenerated the affected packages to ensure that they are consistent with the current version of mksyscall, which produced some declaration-order changes in internal/syscall/windows/zsyscall_windows.go. Fixes #41916 Updates #25922 Change-Id: If6e6f8ba3dd372a7ecd6820ee6c0ca38d55f0f35 Reviewed-on: https://go-review.googlesource.com/c/go/+/261499 Trust: Bryan C. Mills Trust: Alex Brainman Reviewed-by: Dmitri Shuralyov Reviewed-by: Alex Brainman --- src/syscall/syscall.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/syscall/syscall.go') diff --git a/src/syscall/syscall.go b/src/syscall/syscall.go index 980ef9d27f..2e7a3ae5f2 100644 --- a/src/syscall/syscall.go +++ b/src/syscall/syscall.go @@ -26,7 +26,7 @@ // package syscall -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -systemdll -output zsyscall_windows.go syscall_windows.go security_windows.go +//go:generate go run ./mksyscall_windows.go -systemdll -output zsyscall_windows.go syscall_windows.go security_windows.go // StringByteSlice converts a string to a NUL-terminated []byte, // If s contains a NUL byte this function panics instead of -- cgit v1.3 From e012d0dc34e0c182aed605347fb19c6980b3f8bd Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 10 Dec 2020 15:01:20 -0800 Subject: syscall: drop references to Unix epoch in Timeval/Timespec docs The various conversion functions just change the format of time values. They don't use the Unix epoch. Although in practice the values are often times since the Unix epoch, they aren't always, so referring to the epoch can be confusing. Fixes #43010 Change-Id: I640d665f0d2017f0974db05d70858037c7c91eda Reviewed-on: https://go-review.googlesource.com/c/go/+/277073 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Brad Fitzpatrick TryBot-Result: Go Bot --- src/syscall/syscall.go | 10 ++++------ src/syscall/timestruct.go | 12 ++++-------- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'src/syscall/syscall.go') diff --git a/src/syscall/syscall.go b/src/syscall/syscall.go index 2e7a3ae5f2..91173033ee 100644 --- a/src/syscall/syscall.go +++ b/src/syscall/syscall.go @@ -77,24 +77,22 @@ func BytePtrFromString(s string) (*byte, error) { // See mksyscall.pl. var _zero uintptr -// Unix returns ts as the number of seconds and nanoseconds elapsed since the -// Unix epoch. +// Unix returns the time stored in ts as seconds plus nanoseconds. func (ts *Timespec) Unix() (sec int64, nsec int64) { return int64(ts.Sec), int64(ts.Nsec) } -// Unix returns tv as the number of seconds and nanoseconds elapsed since the -// Unix epoch. +// Unix returns the time stored in tv as seconds plus nanoseconds. func (tv *Timeval) Unix() (sec int64, nsec int64) { return int64(tv.Sec), int64(tv.Usec) * 1000 } -// Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. +// Nano returns the time stored in ts as nanoseconds. func (ts *Timespec) Nano() int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } -// Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. +// Nano returns the time stored in tv as nanoseconds. func (tv *Timeval) Nano() int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 } diff --git a/src/syscall/timestruct.go b/src/syscall/timestruct.go index 682c68cf9b..bca51df08d 100644 --- a/src/syscall/timestruct.go +++ b/src/syscall/timestruct.go @@ -6,12 +6,10 @@ package syscall -// TimespecToNsec converts a Timespec value into a number of -// nanoseconds since the Unix epoch. +// TimespecToNSec returns the time stored in ts as nanoseconds. func TimespecToNsec(ts Timespec) int64 { return ts.Nano() } -// NsecToTimespec takes a number of nanoseconds since the Unix epoch -// and returns the corresponding Timespec value. +// NsecToTimespec converts a number of nanoseconds into a Timespec. func NsecToTimespec(nsec int64) Timespec { sec := nsec / 1e9 nsec = nsec % 1e9 @@ -22,12 +20,10 @@ func NsecToTimespec(nsec int64) Timespec { return setTimespec(sec, nsec) } -// TimevalToNsec converts a Timeval value into a number of nanoseconds -// since the Unix epoch. +// TimevalToNsec returns the time stored in tv as nanoseconds. func TimevalToNsec(tv Timeval) int64 { return tv.Nano() } -// NsecToTimeval takes a number of nanoseconds since the Unix epoch -// and returns the corresponding Timeval value. +// NsecToTimeval converts a number of nanoseconds into a Timeval. func NsecToTimeval(nsec int64) Timeval { nsec += 999 // round up to microsecond usec := nsec % 1e9 / 1e3 -- cgit v1.3